From 74900ecd4942cb21f89b3bebea43c4b844eba78e Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Tue, 5 Mar 2024 17:43:20 +0100 Subject: [PATCH] fix: options for the extra metrics handler of the controller manager need to be set before creating the manager --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index daa07c03..c09243b5 100644 --- a/main.go +++ b/main.go @@ -416,15 +416,15 @@ func setupTelemetryServices(opts telemetryOptions) { } func setupManager(options ctrl.Options) (ctrl.Manager, error) { + if options.Metrics.BindAddress != "0" { + options.Metrics.ExtraHandlers = map[string]http.Handler{"/server-metrics": promhttp.Handler()} + } + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options) if err != nil { return nil, err } - if options.Metrics.BindAddress != "0" { - options.Metrics.ExtraHandlers = map[string]http.Handler{"/server-metrics": promhttp.Handler()} - } - if options.HealthProbeBindAddress != "0" { if err := mgr.AddHealthzCheck("ping", healthz.Ping); err != nil { return nil, err