Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
wking committed Jun 16, 2020
commit 07e5809d54db9d5a66b798fd9909c76e0dc818b4
6 changes: 2 additions & 4 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type Options struct {
Name string
Namespace string
PayloadOverride string
EnableMetrics bool
ResyncInterval time.Duration
}

Expand All @@ -99,7 +98,6 @@ func NewOptions() *Options {
Name: defaultEnv("CVO_NAME", defaultComponentName),
PayloadOverride: os.Getenv("PAYLOAD_OVERRIDE"),
ResyncInterval: minResyncPeriod,
EnableMetrics: true,
Exclude: os.Getenv("EXCLUDE_MANIFESTS"),
}
}
Expand Down Expand Up @@ -191,7 +189,7 @@ func (o *Options) makeTLSConfig() (*tls.Config, error) {

func (o *Options) run(ctx context.Context, controllerCtx *Context, lock *resourcelock.ConfigMapLock) {
// listen on metrics
if len(o.ListenAddr) > 0 {
if o.ListenAddr != "" {
handler := http.NewServeMux()
handler.Handle("/metrics", promhttp.Handler())
tcpl, err := net.Listen("tcp", o.ListenAddr)
Expand Down Expand Up @@ -422,7 +420,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
sharedInformers.Config().V1().Proxies(),
cb.ClientOrDie(o.Namespace),
cb.KubeClientOrDie(o.Namespace, useProtobuf),
o.EnableMetrics,
o.ListenAddr != "",
o.Exclude,
),
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/start/start_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func TestIntegrationCVO_initializeAndUpgrade(t *testing.T) {
options.NodeName = "test-node"
options.ReleaseImage = payloadImage1
options.PayloadOverride = filepath.Join(dir, "ignored")
options.EnableMetrics = false
controllers := options.NewControllerContext(cb)

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

Expand Down Expand Up @@ -497,7 +495,6 @@ func TestIntegrationCVO_gracefulStepDown(t *testing.T) {
options.Name = ns
options.ListenAddr = ""
options.NodeName = "test-node"
options.EnableMetrics = false
controllers := options.NewControllerContext(cb)

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