From 24c4ec5d5c70c7d0ae87886e5938f27e4eb15a5a Mon Sep 17 00:00:00 2001 From: Marcel Fest Date: Mon, 22 Apr 2024 08:54:10 +0200 Subject: [PATCH] Add possibility to enable pprof via config --- cmd/manager/main.go | 3 +-- pkg/managerconfig/managerconfig.go | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 44c44e90..a6fb97c0 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -117,8 +117,7 @@ func main() { } else { options = ctrl.Options{Scheme: scheme} } - - if options.MetricsBindAddress != "0" { + if options.MetricsBindAddress != "0" && options.MetricsBindAddress != "" { err = initCollectors() if err != nil { setupLog.Error(err, "unable to initialize metrics collectors") diff --git a/pkg/managerconfig/managerconfig.go b/pkg/managerconfig/managerconfig.go index 49f15acd..def6e5f2 100644 --- a/pkg/managerconfig/managerconfig.go +++ b/pkg/managerconfig/managerconfig.go @@ -13,7 +13,8 @@ import ( // Config holds internal config that is used to create manger.Options struct. type Config struct { Health HealthCfg `yaml:"health"` - Metrics MetricsCfg `yaml:"metrics"` + Metrics ServerConfig `yaml:"metrics"` + Pprof ServerConfig `yaml:"pprof"` Webhook WebhookCfg `yaml:"webhook"` LeaderElection LeaderElectionCfg `yaml:"leaderElection"` } @@ -24,7 +25,7 @@ type HealthCfg struct { } // MetricsCfg holds internal config for metrics options of manger.Options struct. -type MetricsCfg struct { +type ServerConfig struct { BindAddress string `yaml:"bindAddress"` } @@ -68,6 +69,7 @@ func prepareManagerOptions(cfg *Config, scheme *runtime.Scheme) manager.Options Scheme: scheme, HealthProbeBindAddress: cfg.Health.HealthProbeBindAddress, MetricsBindAddress: cfg.Metrics.BindAddress, + PprofBindAddress: cfg.Pprof.BindAddress, WebhookServer: &webhook.DefaultServer{ Options: webhook.Options{ Port: cfg.Webhook.Port,