diff --git a/cmd/kperf/commands/runner/runner.go b/cmd/kperf/commands/runner/runner.go index 52acd09..43d371b 100644 --- a/cmd/kperf/commands/runner/runner.go +++ b/cmd/kperf/commands/runner/runner.go @@ -2,15 +2,18 @@ package runner import ( "context" + "flag" "fmt" "os" "path/filepath" + "strconv" "github.com/Azure/kperf/api/types" "github.com/Azure/kperf/request" "github.com/urfave/cli" "gopkg.in/yaml.v2" + "k8s.io/klog/v2" ) // Command represents runner subcommand. @@ -67,8 +70,26 @@ var runCommand = cli.Command{ Name: "result", Usage: "Path to the file which stores results", }, + cli.StringFlag{ + Name: "v", + Usage: "log level for V logs", + Value: "0", + }, }, Action: func(cliCtx *cli.Context) error { + // initialize klog + klog.InitFlags(nil) + + vFlag, err := strconv.Atoi(cliCtx.String("v")) + if err != nil || vFlag < 0 { + return fmt.Errorf("invalid value \"%v\" for flag -v: value must be a non-negative integer", cliCtx.String("v")) + } + if err := flag.Set("v", strconv.Itoa(cliCtx.Int("v"))); err != nil { + return fmt.Errorf("failed to set log level: %w", err) + } + defer klog.Flush() + flag.Parse() + profileCfg, err := loadConfig(cliCtx) if err != nil { return err diff --git a/go.mod b/go.mod index ee4cb79..8224f1e 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( k8s.io/apimachinery v0.28.4 k8s.io/cli-runtime v0.28.4 k8s.io/client-go v0.28.4 + k8s.io/klog/v2 v2.100.1 k8s.io/kubectl v0.28.4 ) @@ -135,7 +136,6 @@ require ( k8s.io/apiextensions-apiserver v0.28.4 // indirect k8s.io/apiserver v0.28.4 // indirect k8s.io/component-base v0.28.4 // indirect - k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect oras.land/oras-go v1.2.4 // indirect diff --git a/manifests/virtualcluster/nodes/Chart.yaml b/manifests/virtualcluster/nodes/Chart.yaml index 567ab84..5ec7b6f 100644 --- a/manifests/virtualcluster/nodes/Chart.yaml +++ b/manifests/virtualcluster/nodes/Chart.yaml @@ -1,4 +1,5 @@ { + apiVersion: v1, "name": "virtualnodes", "version": "0.0.1" } diff --git a/manifests/virtualcluster/nodes/values.yaml b/manifests/virtualcluster/nodes/values.yaml index fa21288..931b0b9 100644 --- a/manifests/virtualcluster/nodes/values.yaml +++ b/manifests/virtualcluster/nodes/values.yaml @@ -1,4 +1,4 @@ -name: "" +name: "vc-testing" controllerNodeSelectors: {} replicas: 0 nodeLabels: {} diff --git a/request/schedule.go b/request/schedule.go index 64075ff..2cd926b 100644 --- a/request/schedule.go +++ b/request/schedule.go @@ -12,6 +12,7 @@ import ( "golang.org/x/time/rate" "k8s.io/client-go/rest" + "k8s.io/klog/v2" ) const defaultTimeout = 60 * time.Second @@ -55,7 +56,10 @@ func Schedule(ctx context.Context, spec *types.LoadProfileSpec, restCli []rest.I for builder := range reqBuilderCh { _, req := builder.Build(cli) + klog.V(9).Infof("Request URL: %s", req.URL()) + if err := limiter.Wait(ctx); err != nil { + klog.V(9).Infof("Rate limiter wait failed: %v", err) cancel() return } @@ -77,6 +81,7 @@ func Schedule(ctx context.Context, spec *types.LoadProfileSpec, restCli []rest.I if err != nil { respMetric.ObserveFailure(err) + klog.V(9).Infof("Request stream failed: %v", err) } }() }