Skip to content

Commit d10b8ca

Browse files
Merge pull request #797 from stuggi/operator_sdk_1.41.1_pprofBindAddress
Add pprof-bind-address flag support
2 parents 3a3c9d1 + 4b9b597 commit d10b8ca

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

cmd/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ func main() {
102102
var webhookCertPath, webhookCertName, webhookCertKey string
103103
var enableLeaderElection bool
104104
var probeAddr string
105+
var pprofBindAddress string
106+
var webhookPort int
105107
var secureMetrics bool
106108
var enableHTTP2 bool
107109
var tlsOpts []func(*tls.Config)
@@ -120,6 +122,8 @@ func main() {
120122
"The directory that contains the metrics server certificate.")
121123
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
122124
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
125+
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
126+
flag.IntVar(&webhookPort, "webhook-bind-address", 9443, "The port the webhook server binds to.")
123127
flag.BoolVar(&enableHTTP2, "enable-http2", false,
124128
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
125129
opts := zap.Options{
@@ -171,6 +175,7 @@ func main() {
171175
}
172176

173177
webhookServer := webhook.NewServer(webhook.Options{
178+
Port: webhookPort,
174179
TLSOpts: webhookTLSOpts,
175180
})
176181

@@ -235,6 +240,7 @@ func main() {
235240
Metrics: metricsServerOptions,
236241
WebhookServer: webhookServer,
237242
HealthProbeBindAddress: probeAddr,
243+
PprofBindAddress: pprofBindAddress,
238244
LeaderElection: enableLeaderElection,
239245
LeaderElectionID: "fa1814a2.openstack.org",
240246
}

hack/run_with_local_webhook.sh

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

306-
go run ./cmdmain.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}" -webhook-bind-address "${WEBHOOK_PORT}"
306+
go run ./cmd/main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}" -webhook-bind-address "${WEBHOOK_PORT}"

0 commit comments

Comments
 (0)