Skip to content

Commit dfbf3b7

Browse files
Merge pull request #1479 from dprince/pprof
Add pprof-bind-address option to main.go's
2 parents 2641fcf + 7a83721 commit dfbf3b7

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,24 @@ build: generate fmt vet ## Build manager binary.
219219
.PHONY: run
220220
run: export METRICS_PORT?=8080
221221
run: export HEALTH_PORT?=8081
222+
run: export PPROF_PORT?=8082
222223
run: export ENABLE_WEBHOOKS?=false
223224
run: manifests generate fmt vet ## Run a controller from your host.
224225
/bin/bash hack/clean_local_webhook.sh
225226
source hack/export_related_images.sh && \
226-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
227+
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
227228

228229
.PHONY: run-operator
229230
run-operator: export METRICS_PORT?=8080
230231
run-operator: export HEALTH_PORT?=8081
232+
run: export PPROF_PORT?=8082
231233
run-operator: export ENABLE_WEBHOOKS?=false
232234
run-operator: export BASE_BINDATA?=bindata
233235
run-operator: export OPERATOR_IMAGE_URL=${IMG}
234236
run-operator: manifests generate fmt vet ## Run a controller from your host.
235237
source hack/export_related_images.sh && \
236238
source hack/export_operator_related_images.sh && \
237-
go run ./cmd/operator/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
239+
go run ./cmd/operator/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
238240

239241
.PHONY: docker-build
240242
docker-build: ## Build docker image with the manager.
@@ -502,6 +504,7 @@ SKIP_CERT ?=false
502504
.PHONY: run-with-webhook
503505
run-with-webhook: export METRICS_PORT?=8080
504506
run-with-webhook: export HEALTH_PORT?=8081
507+
run-with-webhook: export PPROF_PORT?=8082
505508
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
506509
/bin/bash hack/run_with_local_webhook.sh
507510

cmd/operator/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ func main() {
6262
var enableLeaderElection bool
6363
var probeAddr string
6464
var enableHTTP2 bool
65+
var pprofAddr string
6566
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
6667
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
6768
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
69+
flag.StringVar(&pprofAddr, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof")
6870
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6971
"Enable leader election for controller manager. "+
7072
"Enabling this will ensure there is only one active controller manager.")
@@ -93,6 +95,7 @@ func main() {
9395
Metrics: metricsserver.Options{
9496
BindAddress: metricsAddr,
9597
},
98+
PprofBindAddress: pprofAddr,
9699
HealthProbeBindAddress: probeAddr,
97100
LeaderElection: enableLeaderElection,
98101
LeaderElectionID: "20ca801f.openstack.org",

hack/run_with_local_webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,4 @@ if [ -n "${CSV_NAME}" ]; then
402402
fi
403403

404404
source hack/export_related_images.sh && \
405-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}"
405+
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
@@ -139,10 +139,12 @@ func main() {
139139
var metricsAddr string
140140
var enableLeaderElection bool
141141
var probeAddr string
142+
var pprofAddr string
142143
var enableHTTP2 bool
143144
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
144145
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
145146
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
147+
flag.StringVar(&pprofAddr, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof")
146148
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
147149
"Enable leader election for controller manager. "+
148150
"Enabling this will ensure there is only one active controller manager.")
@@ -171,6 +173,7 @@ func main() {
171173
Metrics: metricsserver.Options{
172174
BindAddress: metricsAddr,
173175
},
176+
PprofBindAddress: pprofAddr,
174177
HealthProbeBindAddress: probeAddr,
175178
LeaderElection: enableLeaderElection,
176179
LeaderElectionID: "40ba705e.openstack.org",

0 commit comments

Comments
 (0)