From d411f91a8b9f09ebd0747e3d79f4c1f51397311d Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Fri, 29 Mar 2024 07:53:09 +0000 Subject: [PATCH] contrib: fix args issue We should not render args if input is empty. Signed-off-by: Wei Fu --- contrib/cmd/runkperf/commands/bench/root.go | 2 +- contrib/internal/utils/kperf_cmd.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/contrib/cmd/runkperf/commands/bench/root.go b/contrib/cmd/runkperf/commands/bench/root.go index 52d9eed..df3906c 100644 --- a/contrib/cmd/runkperf/commands/bench/root.go +++ b/contrib/cmd/runkperf/commands/bench/root.go @@ -7,8 +7,8 @@ import ( "github.com/Azure/kperf/api/types" kperfcmdutils "github.com/Azure/kperf/cmd/kperf/commands/utils" + "github.com/Azure/kperf/contrib/internal/manifests" "github.com/Azure/kperf/contrib/internal/utils" - "github.com/Azure/kperf/manifests" "k8s.io/klog/v2" "github.com/urfave/cli" diff --git a/contrib/internal/utils/kperf_cmd.go b/contrib/internal/utils/kperf_cmd.go index a937f42..2330d94 100644 --- a/contrib/internal/utils/kperf_cmd.go +++ b/contrib/internal/utils/kperf_cmd.go @@ -36,9 +36,13 @@ func (kr *KperfRunner) NewNodepool( fmt.Sprintf("--cpu=%v", 32), fmt.Sprintf("--memory=%v", 96), fmt.Sprintf("--max-pods=%v", maxPods), - fmt.Sprintf("--affinity=%v", affinity), - fmt.Sprintf("--shared-provider-id=%v", sharedProviderID), ) + if affinity != "" { + args = append(args, fmt.Sprintf("--affinity=%v", affinity)) + } + if sharedProviderID != "" { + args = append(args, fmt.Sprintf("--shared-provider-id=%v", sharedProviderID)) + } _, err := runCommand(ctx, timeout, "kperf", args) return err @@ -65,8 +69,10 @@ func (kr *KperfRunner) RGRun(ctx context.Context, timeout time.Duration, rgCfgPa args = append(args, "run", fmt.Sprintf("--runnergroup=file://%v", rgCfgPath), fmt.Sprintf("--runner-image=%v", kr.runnerImage), - fmt.Sprintf("--affinity=%v", affinity), ) + if affinity != "" { + args = append(args, fmt.Sprintf("--affinity=%v", affinity)) + } if flowcontrol != "" { args = append(args, fmt.Sprintf("--runner-flowcontrol=%v", flowcontrol)) }