From 960184162f1d0f811421317214b44075bc9bafa1 Mon Sep 17 00:00:00 2001 From: Xinwei Liu Date: Wed, 6 Aug 2025 14:58:18 +1000 Subject: [PATCH 1/3] Add namePattern parameter to CreateConfigmaps func Allow customizing ConfigMap naming pattern instead of using fixed "runkperf-bench" default. Falls back to default if empty string provided. --- contrib/cmd/runkperf/commands/bench/list_configmaps.go | 2 +- contrib/utils/utils.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/contrib/cmd/runkperf/commands/bench/list_configmaps.go b/contrib/cmd/runkperf/commands/bench/list_configmaps.go index 75598c29..6fb843e9 100644 --- a/contrib/cmd/runkperf/commands/bench/list_configmaps.go +++ b/contrib/cmd/runkperf/commands/bench/list_configmaps.go @@ -74,7 +74,7 @@ func benchListConfigmapsRun(cliCtx *cli.Context) (*internaltypes.BenchmarkReport cmSize := cliCtx.Int("size") cmGroupSize := cliCtx.Int("group-size") - err = utils.CreateConfigmaps(ctx, kubeCfgPath, cmAmount, cmSize, cmGroupSize, benchConfigmapNamespace, 0) + err = utils.CreateConfigmaps(ctx, kubeCfgPath, benchConfigmapNamespace, "runkperf-bench", cmAmount, cmSize, cmGroupSize, 0) if err != nil { return nil, err } diff --git a/contrib/utils/utils.go b/contrib/utils/utils.go index fbb7c5b0..ce588d2d 100644 --- a/contrib/utils/utils.go +++ b/contrib/utils/utils.go @@ -544,13 +544,16 @@ func CreateTempFileWithContent(data []byte) (_name string, _cleanup func() error } // Creates configmaps for benchmark. -func CreateConfigmaps(ctx context.Context, kubeCfgPath string, - cmAmount int, cmSize int, cmGroupSize int, namespace string, timeout time.Duration) error { +func CreateConfigmaps(ctx context.Context, kubeCfgPath, namespace, namePattern string, + cmAmount, cmSize, cmGroupSize int, timeout time.Duration) error { args := []string{"data", "configmap"} if kubeCfgPath != "" { args = append(args, fmt.Sprintf("--kubeconfig=%s", kubeCfgPath)) } - args = append(args, fmt.Sprintf("--namespace=%s", namespace), "add", "runkperf-bench") + if namePattern == "" { + namePattern = "runkperf-bench" + } + args = append(args, fmt.Sprintf("--namespace=%s", namespace), "add", namePattern) args = append(args, fmt.Sprintf("--total=%d", cmAmount)) args = append(args, fmt.Sprintf("--size=%d", cmSize)) args = append(args, fmt.Sprintf("--group-size=%d", cmGroupSize)) From c3696b79e2077efd7572e1a5884fdc1f867b282d Mon Sep 17 00:00:00 2001 From: Xinwei Liu Date: Thu, 7 Aug 2025 16:48:48 +1000 Subject: [PATCH 2/3] Add namePattern parameter to DeleteConfigmaps func --- contrib/cmd/runkperf/commands/bench/list_configmaps.go | 2 +- contrib/utils/utils.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/cmd/runkperf/commands/bench/list_configmaps.go b/contrib/cmd/runkperf/commands/bench/list_configmaps.go index 6fb843e9..b17da224 100644 --- a/contrib/cmd/runkperf/commands/bench/list_configmaps.go +++ b/contrib/cmd/runkperf/commands/bench/list_configmaps.go @@ -81,7 +81,7 @@ func benchListConfigmapsRun(cliCtx *cli.Context) (*internaltypes.BenchmarkReport defer func() { // Delete the configmaps after the benchmark - err = utils.DeleteConfigmaps(ctx, kubeCfgPath, benchConfigmapNamespace, 0) + err = utils.DeleteConfigmaps(ctx, kubeCfgPath, benchConfigmapNamespace, "runkperf-bench", 0) if err != nil { log.GetLogger(ctx).WithKeyValues("level", "error"). LogKV("msg", fmt.Sprintf("Failed to delete configmaps: %v", err)) diff --git a/contrib/utils/utils.go b/contrib/utils/utils.go index ce588d2d..dc1a8c1c 100644 --- a/contrib/utils/utils.go +++ b/contrib/utils/utils.go @@ -564,12 +564,12 @@ func CreateConfigmaps(ctx context.Context, kubeCfgPath, namespace, namePattern s } // Delete configmaps for benchmark. -func DeleteConfigmaps(ctx context.Context, kubeCfgPath string, namespace string, timeout time.Duration) error { +func DeleteConfigmaps(ctx context.Context, kubeCfgPath, namespace, namePattern string, timeout time.Duration) error { args := []string{"data", "configmap"} if kubeCfgPath != "" { - args = append(args, "--kubeconfig=%s", kubeCfgPath) + args = append(args, fmt.Sprintf("--kubeconfig=%s", kubeCfgPath)) } - args = append(args, fmt.Sprintf("--namespace=%s", namespace), "delete", "runkperf-bench") + args = append(args, fmt.Sprintf("--namespace=%s", namespace), "delete", namePattern) _, err := runCommand(ctx, timeout, "runkperf", args) return err From 2f100fe52fb4ff1a12cb54aba97870f88a495623 Mon Sep 17 00:00:00 2001 From: Xinwei Liu Date: Wed, 13 Aug 2025 09:36:44 +1000 Subject: [PATCH 3/3] Remove default namePattern fallback in CreateConfigmaps --- contrib/utils/utils.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/utils/utils.go b/contrib/utils/utils.go index dc1a8c1c..92c67188 100644 --- a/contrib/utils/utils.go +++ b/contrib/utils/utils.go @@ -550,9 +550,7 @@ func CreateConfigmaps(ctx context.Context, kubeCfgPath, namespace, namePattern s if kubeCfgPath != "" { args = append(args, fmt.Sprintf("--kubeconfig=%s", kubeCfgPath)) } - if namePattern == "" { - namePattern = "runkperf-bench" - } + args = append(args, fmt.Sprintf("--namespace=%s", namespace), "add", namePattern) args = append(args, fmt.Sprintf("--total=%d", cmAmount)) args = append(args, fmt.Sprintf("--size=%d", cmSize))