Skip to content

Commit 07e5809

Browse files
committed
pkg/start: Drop the internal EnableMetrics
We've had it since 2b81f47 (cvo: Release our leader lease when we are gracefully terminated, 2019-01-16, #87), but it's redundant vs. "ListenAddr is not an empty string". I'm also switching to: o.ListenAddr != "" instead of: len(o.ListenAddr) > 0 because it seems slightly easier to understand, but obviously either will work.
1 parent fc25a6f commit 07e5809

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

pkg/start/start.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ type Options struct {
7575
Name string
7676
Namespace string
7777
PayloadOverride string
78-
EnableMetrics bool
7978
ResyncInterval time.Duration
8079
}
8180

@@ -99,7 +98,6 @@ func NewOptions() *Options {
9998
Name: defaultEnv("CVO_NAME", defaultComponentName),
10099
PayloadOverride: os.Getenv("PAYLOAD_OVERRIDE"),
101100
ResyncInterval: minResyncPeriod,
102-
EnableMetrics: true,
103101
Exclude: os.Getenv("EXCLUDE_MANIFESTS"),
104102
}
105103
}
@@ -191,7 +189,7 @@ func (o *Options) makeTLSConfig() (*tls.Config, error) {
191189

192190
func (o *Options) run(ctx context.Context, controllerCtx *Context, lock *resourcelock.ConfigMapLock) {
193191
// listen on metrics
194-
if len(o.ListenAddr) > 0 {
192+
if o.ListenAddr != "" {
195193
handler := http.NewServeMux()
196194
handler.Handle("/metrics", promhttp.Handler())
197195
tcpl, err := net.Listen("tcp", o.ListenAddr)
@@ -422,7 +420,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
422420
sharedInformers.Config().V1().Proxies(),
423421
cb.ClientOrDie(o.Namespace),
424422
cb.KubeClientOrDie(o.Namespace, useProtobuf),
425-
o.EnableMetrics,
423+
o.ListenAddr != "",
426424
o.Exclude,
427425
),
428426
}

pkg/start/start_integration_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ func TestIntegrationCVO_initializeAndUpgrade(t *testing.T) {
238238
options.NodeName = "test-node"
239239
options.ReleaseImage = payloadImage1
240240
options.PayloadOverride = filepath.Join(dir, "ignored")
241-
options.EnableMetrics = false
242241
controllers := options.NewControllerContext(cb)
243242

244243
worker := cvo.NewSyncWorker(retriever, cvo.NewResourceBuilder(cfg, cfg, nil), 5*time.Second, wait.Backoff{Steps: 3}, "")
@@ -390,7 +389,6 @@ func TestIntegrationCVO_initializeAndHandleError(t *testing.T) {
390389
options.NodeName = "test-node"
391390
options.ReleaseImage = payloadImage1
392391
options.PayloadOverride = filepath.Join(dir, "ignored")
393-
options.EnableMetrics = false
394392
options.ResyncInterval = 3 * time.Second
395393
controllers := options.NewControllerContext(cb)
396394

@@ -497,7 +495,6 @@ func TestIntegrationCVO_gracefulStepDown(t *testing.T) {
497495
options.Name = ns
498496
options.ListenAddr = ""
499497
options.NodeName = "test-node"
500-
options.EnableMetrics = false
501498
controllers := options.NewControllerContext(cb)
502499

503500
worker := cvo.NewSyncWorker(&mapPayloadRetriever{}, cvo.NewResourceBuilder(cfg, cfg, nil), 5*time.Second, wait.Backoff{Steps: 3}, "")
@@ -667,7 +664,6 @@ metadata:
667664
options.NodeName = "test-node"
668665
options.ReleaseImage = payloadImage1
669666
options.PayloadOverride = payloadDir
670-
options.EnableMetrics = false
671667
controllers := options.NewControllerContext(cb)
672668
if err := controllers.CVO.InitializeFromPayload(cb.RestConfig(defaultQPS), cb.RestConfig(highQPS)); err != nil {
673669
t.Fatal(err)

0 commit comments

Comments
 (0)