@@ -9,11 +9,6 @@ import (
99 "net/url"
1010 "strings"
1111 "time"
12-
13- "github.com/Azure/kperf/contrib/internal/mountns"
14- "golang.org/x/sys/unix"
15-
16- "k8s.io/klog/v2"
1712)
1813
1914// KubectlRunner is the wrapper of exec.Command to execute kubectl command.
@@ -57,43 +52,6 @@ func (kr *KubectlRunner) FQDN(ctx context.Context, timeout time.Duration) (strin
5752 return strings .ToLower (host ), nil
5853}
5954
60- // Metrics returns the metrics for a specific kube-apiserver.
61- func (kr * KubectlRunner ) Metrics (ctx context.Context , timeout time.Duration , fqdn , ip string ) ([]byte , error ) {
62- args := []string {}
63- if kr .kubeCfgPath != "" {
64- args = append (args , "--kubeconfig" , kr .kubeCfgPath )
65- }
66- args = append (args , "get" , "--raw" , "/metrics" )
67-
68- var result []byte
69-
70- merr := mountns .Executes (func () error {
71- newETCHostFile , cleanup , err := CreateTempFileWithContent ([]byte (fmt .Sprintf ("%s %s\n " , ip , fqdn )))
72- if err != nil {
73- return err
74- }
75- defer func () { _ = cleanup () }()
76-
77- target := "/etc/hosts"
78-
79- err = unix .Mount (newETCHostFile , target , "none" , unix .MS_BIND , "" )
80- if err != nil {
81- return fmt .Errorf ("failed to mount %s on %s: %w" ,
82- newETCHostFile , target , err )
83- }
84- defer func () {
85- derr := unix .Unmount (target , 0 )
86- if derr != nil {
87- klog .Warningf ("failed umount %s" , target )
88- }
89- }()
90-
91- result , err = runCommand (ctx , timeout , "kubectl" , args )
92- return err
93- })
94- return result , merr
95- }
96-
9755// Wait runs wait subcommand.
9856func (kr * KubectlRunner ) Wait (ctx context.Context , timeout time.Duration , condition , waitTimeout , target string ) error {
9957 if condition == "" {
0 commit comments