From c8a5562331377d81cd8616ef3ddcac4481d5756b Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Wed, 25 Sep 2024 15:20:01 +0200 Subject: [PATCH] metrics-profile flag implementation Signed-off-by: Raul Sevilla --- cluster-density.go | 4 +++- common.go | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cluster-density.go b/cluster-density.go index 831a3c88..d343ec51 100644 --- a/cluster-density.go +++ b/cluster-density.go @@ -33,6 +33,7 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm var churnDelay, churnDuration time.Duration var churnDeletionStrategy string var podReadyThreshold time.Duration + var metricsProfile []string cmd := &cobra.Command{ Use: variant, Short: fmt.Sprintf("Runs %v workload", variant), @@ -60,7 +61,7 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm log.Errorf("image-registry deployment is not deployed") } } - setMetrics(cmd, "metrics-aggregated.yml") + setMetrics(cmd, metricsProfile...) wh.Run(cmd.Name()) }, } @@ -73,6 +74,7 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm cmd.Flags().IntVar(&churnPercent, "churn-percent", 10, "Percentage of job iterations that kube-burner will churn each round") cmd.Flags().StringVar(&churnDeletionStrategy, "churn-deletion-strategy", "default", "Churn deletion strategy to use") cmd.Flags().BoolVar(&svcLatency, "service-latency", false, "Enable service latency measurement") + cmd.Flags().StringSliceVar(&metricsProfile, "metrics-profile", []string{"metrics-aggregated.yml"}, "Comma separated list of metrics profiles to use") cmd.MarkFlagRequired("iterations") return cmd } diff --git a/common.go b/common.go index 543ac99d..9b7a3f43 100644 --- a/common.go +++ b/common.go @@ -28,16 +28,13 @@ import ( var clusterMetadata ocpmetadata.ClusterMetadata -func setMetrics(cmd *cobra.Command, metricsProfile string) { - var metricsProfiles []string +func setMetrics(cmd *cobra.Command, metricsProfiles ...string) { profileType, _ := cmd.Root().PersistentFlags().GetString("profile-type") switch ProfileType(profileType) { case Reporting: metricsProfiles = []string{"metrics-report.yml"} - case Regular: - metricsProfiles = []string{metricsProfile} case Both: - metricsProfiles = []string{"metrics-report.yml", metricsProfile} + metricsProfiles = append(metricsProfiles, "metrics-report.yml") } os.Setenv("METRICS", strings.Join(metricsProfiles, ",")) }