diff --git a/Makefile b/Makefile index 285e42d2..76ca5d77 100644 --- a/Makefile +++ b/Makefile @@ -144,11 +144,12 @@ build: generate fmt vet ## Build manager binary. .PHONY: run run: export METRICS_PORT?=8080 run: export HEALTH_PORT?=8081 +run: export PPROF_PORT?=8082 run: export OPERATOR_TEMPLATES=./templates/ run: export ENABLE_WEBHOOKS?=false run: manifests generate fmt vet ## Run a controller from your host. /bin/bash hack/clean_local_webhook.sh - go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" + go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)" .PHONY: docker-build docker-build: test ## Build docker image with the manager. @@ -376,6 +377,7 @@ SKIP_CERT ?=false .PHONY: run-with-webhook run-with-webhook: export METRICS_PORT?=8080 run-with-webhook: export HEALTH_PORT?=8081 +run-with-webhook: export PPROF_PORT?=8082 run-with-webhook: manifests generate fmt vet ## Run a controller from your host. /bin/bash hack/run_with_local_webhook.sh diff --git a/hack/run_with_local_webhook.sh b/hack/run_with_local_webhook.sh index 64941c45..fe5b6af0 100755 --- a/hack/run_with_local_webhook.sh +++ b/hack/run_with_local_webhook.sh @@ -176,4 +176,4 @@ else oc scale --replicas=0 -n openstack-operators deploy/mariadb-operator-controller-manager fi -go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" +go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}" diff --git a/main.go b/main.go index e27c9b99..fe377669 100644 --- a/main.go +++ b/main.go @@ -61,10 +61,12 @@ func main() { var metricsAddr string var enableLeaderElection bool var probeAddr string + var pprofBindAddress string var enableHTTP2 bool flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.") flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") + flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") @@ -91,6 +93,7 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "7c2a6c6b.openstack.org", + PprofBindAddress: pprofBindAddress, WebhookServer: webhook.NewServer( webhook.Options{ Port: 9443,