Skip to content

Commit 40f384e

Browse files
committed
Add pprof-bind-address option to main.go
Jira: OSPRH-17594
1 parent 1c10700 commit 40f384e

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
@@ -127,10 +127,11 @@ build: generate fmt vet ## Build manager binary.
127127
.PHONY: run
128128
run: export METRICS_PORT?=8080
129129
run: export HEALTH_PORT?=8081
130+
run: export PPROF_PORT?=8082
130131
run: export ENABLE_WEBHOOKS?=false
131132
run: manifests generate fmt vet ## Run a controller from your host.
132133
/bin/bash hack/clean_local_webhook.sh
133-
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)"
134135

135136
# Extra vars which will be passed to the Docker-build
136137
DOCKER_BUILD_ARGS ?=
@@ -351,6 +352,7 @@ SKIP_CERT ?=false
351352
.PHONY: run-with-webhook
352353
run-with-webhook: export METRICS_PORT?=8080
353354
run-with-webhook: export HEALTH_PORT?=8081
355+
run-with-webhook: export PPROF_PORT?=8082
354356
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
355357
/bin/bash hack/run_with_local_webhook.sh
356358

hack/run_with_local_webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,4 @@ else
302302
oc scale --replicas=0 -n openstack-operators deploy/telemetry-operator-controller-manager
303303
fi
304304

305-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}"
305+
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
@@ -88,10 +88,12 @@ func main() {
8888
var metricsAddr string
8989
var enableLeaderElection bool
9090
var probeAddr string
91+
var pprofBindAddress string
9192
var enableHTTP2 bool
9293
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
9394
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8083", "The address the metric endpoint binds to.")
9495
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8084", "The address the probe endpoint binds to.")
96+
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
9597
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
9698
"Enable leader election for controller manager. "+
9799
"Enabling this will ensure there is only one active controller manager.")
@@ -118,6 +120,7 @@ func main() {
118120
HealthProbeBindAddress: probeAddr,
119121
LeaderElection: enableLeaderElection,
120122
LeaderElectionID: "fa1814a2.openstack.org",
123+
PprofBindAddress: pprofBindAddress,
121124
WebhookServer: webhook.NewServer(
122125
webhook.Options{
123126
Port: 9443,

0 commit comments

Comments
 (0)