Skip to content

Commit 3dde352

Browse files
authored
gha: add a flag for enabling pprof (#3)
1 parent 057a1e7 commit 3dde352

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

charts/gha-runner-scale-set-controller/templates/deployment.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ spec:
7979
- "--listener-metrics-endpoint="
8080
- "--metrics-addr=0"
8181
{{- end }}
82+
{{- with .Values.pprof }}
83+
- "--pprof-addr={{ .controllerManagerAddr }}"
84+
{{- end }}
8285
{{- range .Values.flags.excludeLabelPropagationPrefixes }}
8386
- "--exclude-label-propagation-prefix={{ . }}"
8487
{{- end }}
@@ -96,12 +99,19 @@ spec:
9699
{{- end }}
97100
command:
98101
- "/manager"
99-
{{- with .Values.metrics }}
102+
{{- if or .Values.metrics .Values.pprof }}
100103
ports:
104+
{{- end}}
105+
{{- with .Values.metrics }}
101106
- containerPort: {{regexReplaceAll ":([0-9]+)" .controllerManagerAddr "${1}"}}
102107
protocol: TCP
103108
name: metrics
104109
{{- end }}
110+
{{- with .Values.pprof }}
111+
- containerPort: {{regexReplaceAll ":([0-9]+)" .controllerManagerAddr "${1}"}}
112+
protocol: TCP
113+
name: pprof
114+
{{- end }}
105115
env:
106116
- name: CONTROLLER_MANAGER_CONTAINER_IMAGE
107117
value: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"

charts/gha-runner-scale-set-controller/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ priorityClassName: ""
9494
# listenerAddr: ":8080"
9595
# listenerEndpoint: "/metrics"
9696

97+
## To enable pprof, uncomment the following lines.
98+
# pprof:
99+
# controllerManagerAddr: ":8081"
100+
97101
flags:
98102
## Log level can be set here with one of the following values: "debug", "info", "warn", "error".
99103
## Defaults to "debug".

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func main() {
8181
listenerMetricsEndpoint string
8282

8383
metricsAddr string
84+
pprofAddr string
8485
autoScalingRunnerSetOnly bool
8586
enableLeaderElection bool
8687
disableAdmissionWebhook bool
@@ -119,6 +120,7 @@ func main() {
119120
flag.StringVar(&listenerMetricsAddr, "listener-metrics-addr", ":8080", "The address applied to AutoscalingListener metrics server")
120121
flag.StringVar(&listenerMetricsEndpoint, "listener-metrics-endpoint", "/metrics", "The AutoscalingListener metrics server endpoint from which the metrics are collected")
121122
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
123+
flag.StringVar(&pprofAddr, "pprof-addr", "", "The address the pprof endpoint binds to.")
122124
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
123125
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
124126
flag.StringVar(&leaderElectionId, "leader-election-id", "actions-runner-controller", "Controller id for leader election.")
@@ -243,6 +245,7 @@ func main() {
243245
},
244246
},
245247
},
248+
PprofBindAddress: pprofAddr,
246249
})
247250
if err != nil {
248251
log.Error(err, "unable to start manager")

0 commit comments

Comments
 (0)