Skip to content

Commit 9852006

Browse files
Merge pull request #401 from dprince/pprof
Add pprof-bind-address option to main.go
2 parents cbb0f7b + 5c1f87b commit 9852006

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

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 OPERATOR_TEMPLATES=./templates
138139
run: export ENABLE_WEBHOOKS?=false
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
# If you wish built the manager image targeting other platforms you can use the --platform flag.
144145
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
@@ -369,6 +370,7 @@ SKIP_CERT ?=false
369370
.PHONY: run-with-webhook
370371
run-with-webhook: export METRICS_PORT?=8080
371372
run-with-webhook: export HEALTH_PORT?=8081
373+
run-with-webhook: export PPROF_PORT?=8082
372374
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
373375
/bin/bash hack/run_with_local_webhook.sh
374376

hack/run_with_local_webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,4 @@ else
468468
oc scale --replicas=0 -n openstack-operators deploy/infra-operator-controller-manager
469469
fi
470470

471-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}"
471+
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
@@ -84,10 +84,12 @@ func main() {
8484
var metricsAddr string
8585
var enableLeaderElection bool
8686
var probeAddr string
87+
var pprofBindAddress string
8788
var enableHTTP2 bool
8889
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
8990
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
9091
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
92+
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
9193
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
9294
"Enable leader election for controller manager. "+
9395
"Enabling this will ensure there is only one active controller manager.")
@@ -114,6 +116,7 @@ func main() {
114116
HealthProbeBindAddress: probeAddr,
115117
LeaderElection: enableLeaderElection,
116118
LeaderElectionID: "c8c223a1.openstack.org",
119+
PprofBindAddress: pprofBindAddress,
117120
WebhookServer: webhook.NewServer(
118121
webhook.Options{
119122
Port: 9443,

0 commit comments

Comments
 (0)