Skip to content

Commit e42398b

Browse files
committed
Add pprof-bind-address option to main.go
Jira: OSPRH-17594
1 parent 565e4c4 commit e42398b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ build: generate fmt vet ## Build manager binary.
134134
.PHONY: run
135135
run: export METRICS_PORT?=8080
136136
run: export HEALTH_PORT?=8081
137+
run: export PPROF_PORT?=8082
137138
run: export ENABLE_WEBHOOKS?=false
138139
run: export OPERATOR_TEMPLATES=./templates/
139140
run: manifests generate fmt vet ## Run a controller from your host.
140141
/bin/bash hack/clean_local_webhook.sh
141-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
142+
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
142143

143144
.PHONY: docker-build
144145
docker-build: test ## Build docker image with the manager.
@@ -336,6 +337,7 @@ SKIP_CERT ?=false
336337
.PHONY: run-with-webhook
337338
run-with-webhook: export METRICS_PORT?=8080
338339
run-with-webhook: export HEALTH_PORT?=8081
340+
run-with-webhook: export PPROF_PORT?=8082
339341
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
340342
/bin/bash hack/run_with_local_webhook.sh
341343

hack/run_with_local_webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ else
131131
oc scale --replicas=0 -n openstack-operators deploy/designate-operator-controller-manager
132132
fi
133133

134-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}"
134+
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ func main() {
7373
var metricsAddr string
7474
var enableLeaderElection bool
7575
var probeAddr string
76+
var pprofBindAddress string
7677
var enableHTTP2 bool
7778
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
7879
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
7980
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
81+
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
8082
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8183
"Enable leader election for controller manager. "+
8284
"Enabling this will ensure there is only one active controller manager.")
@@ -103,6 +105,7 @@ func main() {
103105
HealthProbeBindAddress: probeAddr,
104106
LeaderElection: enableLeaderElection,
105107
LeaderElectionID: "f9497e05.openstack.org",
108+
PprofBindAddress: pprofBindAddress,
106109
WebhookServer: webhook.NewServer(
107110
webhook.Options{
108111
Port: 9443,

0 commit comments

Comments
 (0)