Skip to content

Commit 9986ddf

Browse files
committed
Fix missing flag registration
1 parent 3687dc6 commit 9986ddf

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

clusterloader2/cmd/clusterloader.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ func initFlags() {
136136

137137
initClusterFlags()
138138
execservice.InitFlags(&clusterLoaderConfig.ExecServiceConfig)
139+
imagepreload.InitFlags()
139140
modifier.InitFlags(&clusterLoaderConfig.ModifierConfig)
140141
prometheus.InitFlags(&clusterLoaderConfig.PrometheusConfig)
142+
prometheus.InitExperimentalFlags()
141143
}
142144

143145
func validateFlags() *errors.ErrorList {

clusterloader2/pkg/imagepreload/imagepreload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var (
5353
manifestsFS embed.FS
5454
)
5555

56-
func init() {
56+
func InitFlags() {
5757
flags.StringSliceEnvVar(&images, "node-preload-images", "NODE_PRELOAD_IMAGES", []string{}, "List of images to preload on each node in the test cluster before executing tests")
5858
}
5959

clusterloader2/pkg/prometheus/experimental.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import (
2727
"regexp"
2828
"time"
2929

30-
"github.com/spf13/pflag"
3130
corev1 "k8s.io/api/core/v1"
3231
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3332
"k8s.io/apimachinery/pkg/util/wait"
3433
"k8s.io/klog/v2"
34+
"k8s.io/perf-tests/clusterloader2/pkg/flags"
3535
)
3636

3737
var (
@@ -50,13 +50,20 @@ const (
5050
)
5151

5252
var (
53-
shouldSnapshotPrometheusDisk = pflag.Bool("experimental-gcp-snapshot-prometheus-disk", false, "(experimental, provider=gce|gke only) whether to snapshot Prometheus disk before Prometheus stack is torn down")
54-
shouldSnapshotPrometheusToReportDir = pflag.Bool("experimental-prometheus-snapshot-to-report-dir", false, "(experimental) whether to save prometheus snapshot to the report-dir")
55-
prometheusDiskSnapshotName = pflag.String("experimental-prometheus-disk-snapshot-name", "", "Name of the prometheus disk snapshot that will be created if snapshots are enabled. If not set, the prometheus disk name will be used.")
53+
shouldSnapshotPrometheusDisk bool
54+
shouldSnapshotPrometheusToReportDir bool
55+
prometheusDiskSnapshotName string
5656
)
5757

58+
// InitExperimentalFlags initializes prometheus flags.
59+
func InitExperimentalFlags() {
60+
flags.BoolVar(&shouldSnapshotPrometheusDisk, "experimental-gcp-snapshot-prometheus-disk", false, "(experimental, provider=gce|gke only) whether to snapshot Prometheus disk before Prometheus stack is torn down")
61+
flags.BoolVar(&shouldSnapshotPrometheusToReportDir, "experimental-prometheus-snapshot-to-report-dir", false, "(experimental) whether to save prometheus snapshot to the report-dir")
62+
flags.StringVar(&prometheusDiskSnapshotName, "experimental-prometheus-disk-snapshot-name", "", "Name of the prometheus disk snapshot that will be created if snapshots are enabled. If not set, the prometheus disk name will be used.")
63+
}
64+
5865
func (pc *Controller) isEnabled() (bool, error) {
59-
if !*shouldSnapshotPrometheusDisk {
66+
if !shouldSnapshotPrometheusDisk {
6067
return false, nil
6168
}
6269
if !pc.provider.Features().SupportSnapshotPrometheusDisk {
@@ -147,7 +154,7 @@ func (pc *Controller) snapshotPrometheusDiskIfEnabledSynchronized() error {
147154
return pc.snapshotError
148155
}
149156
func (pc *Controller) snapshotPrometheusIfEnabled() error {
150-
if !*shouldSnapshotPrometheusToReportDir {
157+
if !shouldSnapshotPrometheusToReportDir {
151158
return nil
152159
}
153160

@@ -168,11 +175,11 @@ func (pc *Controller) snapshotPrometheusDiskIfEnabled() error {
168175
}
169176
// Select snapshot name
170177
snapshotName := pc.diskMetadata.name
171-
if *prometheusDiskSnapshotName != "" {
172-
if err := VerifySnapshotName(*prometheusDiskSnapshotName); err == nil {
173-
snapshotName = *prometheusDiskSnapshotName
178+
if prometheusDiskSnapshotName != "" {
179+
if err := VerifySnapshotName(prometheusDiskSnapshotName); err == nil {
180+
snapshotName = prometheusDiskSnapshotName
174181
} else {
175-
klog.Warningf("Incorrect disk name %v: %v. Using default name: %v", *prometheusDiskSnapshotName, err, snapshotName)
182+
klog.Warningf("Incorrect disk name %v: %v. Using default name: %v", prometheusDiskSnapshotName, err, snapshotName)
176183
}
177184
}
178185
// Snapshot Prometheus disk

clusterloader2/pkg/prometheus/prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func InitFlags(p *config.PrometheusConfig) {
106106
// ValidatePrometheusFlags validates prometheus flags.
107107
func ValidatePrometheusFlags(p *config.PrometheusConfig) *clerrors.ErrorList {
108108
errList := clerrors.NewErrorList()
109-
if *shouldSnapshotPrometheusDisk && p.SnapshotProject == "" {
109+
if shouldSnapshotPrometheusDisk && p.SnapshotProject == "" {
110110
errList.Append(fmt.Errorf("requesting snapshot, but snapshot project not configured. Use --experimental-snapshot-project flag"))
111111
}
112112
return errList

0 commit comments

Comments
 (0)