From 13a03302c8207e3c02d6a9021bb6acbc94d084cc Mon Sep 17 00:00:00 2001 From: Junya Okabe <86868255+Okabe-Junya@users.noreply.github.com> Date: Fri, 24 Apr 2026 17:03:26 +0900 Subject: [PATCH] Add a flag for enabling pprof on the controller manager (#4449) --- .../templates/deployment.yaml | 14 ++++++++++++-- charts/gha-runner-scale-set-controller/values.yaml | 4 ++++ main.go | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/charts/gha-runner-scale-set-controller/templates/deployment.yaml b/charts/gha-runner-scale-set-controller/templates/deployment.yaml index 75f762db..c077b9bc 100644 --- a/charts/gha-runner-scale-set-controller/templates/deployment.yaml +++ b/charts/gha-runner-scale-set-controller/templates/deployment.yaml @@ -84,6 +84,9 @@ spec: - "--listener-metrics-endpoint=" - "--metrics-addr=0" {{- end }} + {{- if .Values.pprof.addr }} + - "--pprof-addr={{ .Values.pprof.addr }}" + {{- end }} {{- range .Values.flags.excludeLabelPropagationPrefixes }} - "--exclude-label-propagation-prefix={{ . }}" {{- end }} @@ -100,12 +103,19 @@ spec: {{- end }} command: - "/manager" - {{- with .Values.metrics }} + {{- if or .Values.metrics .Values.pprof.addr }} ports: - - containerPort: {{regexReplaceAll ":([0-9]+)" .controllerManagerAddr "${1}"}} + {{- end }} + {{- with .Values.metrics }} + - containerPort: {{ required "Values.metrics.controllerManagerAddr must end with a numeric port" (regexFind "[0-9]+$" .controllerManagerAddr) }} protocol: TCP name: metrics {{- end }} + {{- if .Values.pprof.addr }} + - containerPort: {{ required "Values.pprof.addr must end with a numeric port" (regexFind "[0-9]+$" .Values.pprof.addr) }} + protocol: TCP + name: pprof + {{- end }} env: - name: CONTROLLER_MANAGER_CONTAINER_IMAGE value: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" diff --git a/charts/gha-runner-scale-set-controller/values.yaml b/charts/gha-runner-scale-set-controller/values.yaml index a83bdb3a..bc84324f 100644 --- a/charts/gha-runner-scale-set-controller/values.yaml +++ b/charts/gha-runner-scale-set-controller/values.yaml @@ -94,6 +94,10 @@ priorityClassName: "" # listenerAddr: ":8080" # listenerEndpoint: "/metrics" +## To enable pprof, uncomment the addr field below. +pprof: {} +# addr: ":6060" + flags: ## Log level can be set here with one of the following values: "debug", "info", "warn", "error". ## Defaults to "debug". diff --git a/main.go b/main.go index e1879dda..f436d194 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,7 @@ func main() { listenerMetricsEndpoint string metricsAddr string + pprofAddr string autoScalingRunnerSetOnly bool enableLeaderElection bool disableAdmissionWebhook bool @@ -125,6 +126,7 @@ func main() { flag.StringVar(&listenerMetricsAddr, "listener-metrics-addr", ":8080", "The address applied to AutoscalingListener metrics server") flag.StringVar(&listenerMetricsEndpoint, "listener-metrics-endpoint", "/metrics", "The AutoscalingListener metrics server endpoint from which the metrics are collected") flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") + flag.StringVar(&pprofAddr, "pprof-addr", "", "The address the pprof endpoint binds to.") flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") flag.StringVar(&leaderElectionID, "leader-election-id", "actions-runner-controller", "Controller id for leader election.") @@ -244,6 +246,7 @@ func main() { SyncPeriod: &syncPeriod, DefaultNamespaces: defaultNamespaces, }, + PprofBindAddress: pprofAddr, WebhookServer: webhookServer, LeaderElection: enableLeaderElection, LeaderElectionID: leaderElectionID,