diff --git a/contrib/cmd/runkperf/commands/bench/list_configmaps.go b/contrib/cmd/runkperf/commands/bench/list_configmaps.go index 75598c29..b17da224 100644 --- a/contrib/cmd/runkperf/commands/bench/list_configmaps.go +++ b/contrib/cmd/runkperf/commands/bench/list_configmaps.go @@ -74,14 +74,14 @@ 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 } 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 fbb7c5b0..92c67188 100644 --- a/contrib/utils/utils.go +++ b/contrib/utils/utils.go @@ -544,13 +544,14 @@ 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") + + 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)) @@ -561,12 +562,12 @@ func CreateConfigmaps(ctx context.Context, kubeCfgPath string, } // 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