From 642c53f4c9d88fc75864f4e6b5c2f8dcf1698642 Mon Sep 17 00:00:00 2001 From: Lei Yao Date: Sat, 1 Mar 2025 00:15:47 +1100 Subject: [PATCH 1/3] Allows to set verbosity on runner --- cmd/kperf/commands/runnergroup/run.go | 6 ++++++ cmd/kperf/commands/runnergroup/server.go | 8 +++++++- manifests/runnergroup/server/templates/pod.yaml | 2 ++ manifests/runnergroup/server/values.yaml | 1 + runner/group/handler.go | 6 ++++++ runner/runnergroup_run.go | 3 +++ scripts/run_runner.sh | 4 ++-- 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cmd/kperf/commands/runnergroup/run.go b/cmd/kperf/commands/runnergroup/run.go index f5af9a8c..c8318340 100644 --- a/cmd/kperf/commands/runnergroup/run.go +++ b/cmd/kperf/commands/runnergroup/run.go @@ -46,6 +46,11 @@ var runCommand = cli.Command{ Name: "affinity", Usage: "Deploy server to the node with a specific labels (FORMAT: KEY=VALUE[,VALUE])", }, + cli.IntFlag{ + Name: "runner-verbosity", + Usage: "The verbosity level of runners", + Value: 2, + }, }, Action: func(cliCtx *cli.Context) error { imgRef := cliCtx.String("runner-image") @@ -76,6 +81,7 @@ var runCommand = cli.Command{ kubeCfgPath, imgRef, specs[0], + cliCtx.Int("runner-verbosity"), runner.WithRunCmdServerNodeSelectorsOpt(affinityLabels), runner.WithRunCmdRunnerGroupFlowControl(priorityLevel, matchingPrecedence), ) diff --git a/cmd/kperf/commands/runnergroup/server.go b/cmd/kperf/commands/runnergroup/server.go index 45424665..ce2f96fe 100644 --- a/cmd/kperf/commands/runnergroup/server.go +++ b/cmd/kperf/commands/runnergroup/server.go @@ -52,6 +52,11 @@ var serverCommand = cli.Command{ Usage: "The runner result should be stored in that path", Required: true, }, + cli.IntFlag{ + Name: "runner-verbosity", + Usage: "The verbosity level of runners", + Value: 2, + }, }, Hidden: true, Action: func(cliCtx *cli.Context) error { @@ -90,6 +95,7 @@ func buildRunnerGroupHandlers(cliCtx *cli.Context, serverName string) ([]*runner specURIs := cliCtx.StringSlice("runnergroup") imgRef := cliCtx.String("runner-image") namespace := cliCtx.String("namespace") + runnerVerbosity := cliCtx.Int("runner-verbosity") ownerRef := "" if cliCtx.IsSet("runner-owner") { @@ -117,7 +123,7 @@ func buildRunnerGroupHandlers(cliCtx *cli.Context, serverName string) ([]*runner } groupName := fmt.Sprintf("%s-%d", serverName, idx) - g, err := runnergroup.NewHandler(clientset, namespace, groupName, spec, imgRef) + g, err := runnergroup.NewHandler(clientset, namespace, groupName, spec, imgRef, runnerVerbosity) if err != nil { return nil, err } diff --git a/manifests/runnergroup/server/templates/pod.yaml b/manifests/runnergroup/server/templates/pod.yaml index b04af05e..b9c30e3a 100644 --- a/manifests/runnergroup/server/templates/pod.yaml +++ b/manifests/runnergroup/server/templates/pod.yaml @@ -35,6 +35,8 @@ spec: - v1:Pod:$(POD_NAME):$(POD_UID) - --runner-sa - {{ .Values.name }} + - --runner-verbosity + - {{ .Values.runnerVerbosity }} - --address - $(POD_IP):8080 - --address diff --git a/manifests/runnergroup/server/values.yaml b/manifests/runnergroup/server/values.yaml index a1e38097..295bbd14 100644 --- a/manifests/runnergroup/server/values.yaml +++ b/manifests/runnergroup/server/values.yaml @@ -2,6 +2,7 @@ name: "" image: "" # TODO(weifu): need https://github.com/Azure/kperf/issues/25 to support list runnerGroupSpec: "" +runnerVerbosity: "2" nodeSelectors: {} flowcontrol: priorityLevelConfiguration: workload-low diff --git a/runner/group/handler.go b/runner/group/handler.go index b21e9fee..4b09288e 100644 --- a/runner/group/handler.go +++ b/runner/group/handler.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "reflect" + "strconv" "strings" "time" @@ -45,6 +46,8 @@ type Handler struct { imageRef string clientset kubernetes.Interface + + runnerVerbosity int } // NewHandler returns new instance of Handler. @@ -53,6 +56,7 @@ func NewHandler( namespace, name string, spec *types.RunnerGroupSpec, imageRef string, + runnerVerbosity int, ) (*Handler, error) { ownRef, err := buildOwnerReference(spec.OwnerReference) if err != nil { @@ -66,6 +70,7 @@ func NewHandler( ownerRef: ownRef, imageRef: imageRef, clientset: clientset, + runnerVerbosity: runnerVerbosity, }, nil } @@ -417,6 +422,7 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job { }, Command: []string{ "/run_runner.sh", + strconv.Itoa(h.runnerVerbosity), }, }, }, diff --git a/runner/runnergroup_run.go b/runner/runnergroup_run.go index e249d732..1d30d3c1 100644 --- a/runner/runnergroup_run.go +++ b/runner/runnergroup_run.go @@ -36,6 +36,7 @@ func CreateRunnerGroupServer(ctx context.Context, kubeconfigPath string, runnerImage string, rgSpec *types.RunnerGroupSpec, + runnerVerbosity int, opts ...RunCmdOpt, ) error { specInStr, err := tweakAndMarshalSpec(rgSpec) @@ -78,6 +79,8 @@ func CreateRunnerGroupServer(ctx context.Context, "name="+runnerGroupServerReleaseName, "image="+runnerImage, "runnerGroupSpec="+specInStr, + // runnerVerbosity needs to be surrounded by quotes, so that YAML parse it as a string. + fmt.Sprintf("runnerVerbosity=\"%d\"", runnerVerbosity), ), appiler, ) diff --git a/scripts/run_runner.sh b/scripts/run_runner.sh index fe269247..ffefc4d3 100755 --- a/scripts/run_runner.sh +++ b/scripts/run_runner.sh @@ -7,8 +7,8 @@ set -euo pipefail result_file=/data/${POD_NAMESPACE}-${POD_NAME}-${POD_UID}.json -/kperf -v=2 runner run --config=/config/load_profile.yaml \ - --user-agent=${POD_NAME} \ +/kperf -v=$1 runner run --config=/config/load_profile.yaml \ + --user-agent=${POD_NAME} \ --result=${result_file} \ --raw-data From d798498fe86ed542b28686aeed8365799e86bfb0 Mon Sep 17 00:00:00 2001 From: Lei Yao Date: Mon, 3 Mar 2025 09:27:12 +1100 Subject: [PATCH 2/3] Fixes format --- runner/group/handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runner/group/handler.go b/runner/group/handler.go index 4b09288e..c2db5721 100644 --- a/runner/group/handler.go +++ b/runner/group/handler.go @@ -64,12 +64,12 @@ func NewHandler( } return &Handler{ - name: name, - namespace: namespace, - spec: spec, - ownerRef: ownRef, - imageRef: imageRef, - clientset: clientset, + name: name, + namespace: namespace, + spec: spec, + ownerRef: ownRef, + imageRef: imageRef, + clientset: clientset, runnerVerbosity: runnerVerbosity, }, nil } From b788d28c09e6c98e20dc88c0a372762fc53e059e Mon Sep 17 00:00:00 2001 From: Lei Yao Date: Wed, 5 Mar 2025 18:20:06 +1100 Subject: [PATCH 3/3] Use RUNNER_VERBOSITY env var. --- runner/group/handler.go | 5 ++++- scripts/run_runner.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/runner/group/handler.go b/runner/group/handler.go index c2db5721..a5fe1e0b 100644 --- a/runner/group/handler.go +++ b/runner/group/handler.go @@ -409,6 +409,10 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job { Name: "TARGET_URL", Value: uploadURL, }, + { + Name: "RUNNER_VERBOSITY", + Value: strconv.Itoa(h.runnerVerbosity), + }, }, VolumeMounts: []corev1.VolumeMount{ { @@ -422,7 +426,6 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job { }, Command: []string{ "/run_runner.sh", - strconv.Itoa(h.runnerVerbosity), }, }, }, diff --git a/scripts/run_runner.sh b/scripts/run_runner.sh index ffefc4d3..eaa2d509 100755 --- a/scripts/run_runner.sh +++ b/scripts/run_runner.sh @@ -7,7 +7,7 @@ set -euo pipefail result_file=/data/${POD_NAMESPACE}-${POD_NAME}-${POD_UID}.json -/kperf -v=$1 runner run --config=/config/load_profile.yaml \ +/kperf -v=${RUNNER_VERBOSITY} runner run --config=/config/load_profile.yaml \ --user-agent=${POD_NAME} \ --result=${result_file} \ --raw-data