From bf3ba9958ee368a9e18d44abdc1a093b17dff6d8 Mon Sep 17 00:00:00 2001 From: robertdavidsmith <34475852+robertdavidsmith@users.noreply.github.com> Date: Mon, 22 Jul 2024 12:50:09 +0100 Subject: [PATCH] Enable expose profiling port for remaining charts, better profiling error handling (#3809) Co-authored-by: Robert Smith Signed-off-by: Robert Smith --- deployment/armada/templates/deployment.yaml | 2 +- .../armada/templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../armada/templates/profiling-service.yaml | 19 ++++++++++ .../binoculars/templates/deployment.yaml | 2 +- .../templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../templates/profiling-service.yaml | 19 ++++++++++ .../event-ingester/templates/deployment.yaml | 2 +- .../templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../templates/profiling-service.yaml | 19 ++++++++++ deployment/executor/templates/deployment.yaml | 2 +- .../executor/templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../executor/templates/profiling-service.yaml | 19 ++++++++++ .../templates/deployment.yaml | 2 +- .../templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../templates/profiling-service.yaml | 19 ++++++++++ .../lookout-v2/templates/deployment.yaml | 2 +- .../templates/profiling-ingress.yaml | 35 +++++++++++++++++++ .../templates/profiling-service.yaml | 19 ++++++++++ .../scheduler-ingester-profiling-service.yaml | 1 - .../scheduler-profiling-service.yaml | 1 - docs/developer/pprof.md | 5 ++- internal/common/profiling/http.go | 19 ++++++---- 22 files changed, 345 insertions(+), 17 deletions(-) create mode 100644 deployment/armada/templates/profiling-ingress.yaml create mode 100644 deployment/armada/templates/profiling-service.yaml create mode 100644 deployment/binoculars/templates/profiling-ingress.yaml create mode 100644 deployment/binoculars/templates/profiling-service.yaml create mode 100644 deployment/event-ingester/templates/profiling-ingress.yaml create mode 100644 deployment/event-ingester/templates/profiling-service.yaml create mode 100644 deployment/executor/templates/profiling-ingress.yaml create mode 100644 deployment/executor/templates/profiling-service.yaml create mode 100644 deployment/lookout-ingester-v2/templates/profiling-ingress.yaml create mode 100644 deployment/lookout-ingester-v2/templates/profiling-service.yaml create mode 100644 deployment/lookout-v2/templates/profiling-ingress.yaml create mode 100644 deployment/lookout-v2/templates/profiling-service.yaml diff --git a/deployment/armada/templates/deployment.yaml b/deployment/armada/templates/deployment.yaml index 7683e97108f..c1a84e151df 100644 --- a/deployment/armada/templates/deployment.yaml +++ b/deployment/armada/templates/deployment.yaml @@ -72,7 +72,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} volumeMounts: - name: user-config diff --git a/deployment/armada/templates/profiling-ingress.yaml b/deployment/armada/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..be697e47a8b --- /dev/null +++ b/deployment/armada/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "armada.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "armada.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "armada.name" $root }}-server-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "armada.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/armada/templates/profiling-service.yaml b/deployment/armada/templates/profiling-service.yaml new file mode 100644 index 00000000000..dda82cb1ae5 --- /dev/null +++ b/deployment/armada/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "armada.name" . }}-server-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "armada.labels.all" . | nindent 4 }} + name: {{ include "armada.name" . }}-profiling +spec: + selector: + app: {{ include "armada.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/binoculars/templates/deployment.yaml b/deployment/binoculars/templates/deployment.yaml index 2bb8c051a42..51962b2de1f 100644 --- a/deployment/binoculars/templates/deployment.yaml +++ b/deployment/binoculars/templates/deployment.yaml @@ -57,7 +57,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} volumeMounts: - name: user-config diff --git a/deployment/binoculars/templates/profiling-ingress.yaml b/deployment/binoculars/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..ab518bea985 --- /dev/null +++ b/deployment/binoculars/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "binoculars.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "binoculars.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "binoculars.name" $root }}-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "binoculars.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/binoculars/templates/profiling-service.yaml b/deployment/binoculars/templates/profiling-service.yaml new file mode 100644 index 00000000000..455051499eb --- /dev/null +++ b/deployment/binoculars/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "binoculars.name" . }}-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "binoculars.labels.all" . | nindent 4 }} + name: {{ include "binoculars.name" . }}-profiling +spec: + selector: + app: {{ include "binoculars.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/event-ingester/templates/deployment.yaml b/deployment/event-ingester/templates/deployment.yaml index 7c7943aba29..93d1ed42890 100644 --- a/deployment/event-ingester/templates/deployment.yaml +++ b/deployment/event-ingester/templates/deployment.yaml @@ -48,7 +48,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} - containerPort: {{ .Values.applicationConfig.metricsPort }} protocol: TCP diff --git a/deployment/event-ingester/templates/profiling-ingress.yaml b/deployment/event-ingester/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..e90e88b6070 --- /dev/null +++ b/deployment/event-ingester/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "event_ingester.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "event_ingester.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "event_ingester.name" $root }}-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "event_ingester.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/event-ingester/templates/profiling-service.yaml b/deployment/event-ingester/templates/profiling-service.yaml new file mode 100644 index 00000000000..9ff3183f978 --- /dev/null +++ b/deployment/event-ingester/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "event_ingester.name" . }}-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "event_ingester.labels.all" . | nindent 4 }} + name: {{ include "event_ingester.name" . }}-profiling +spec: + selector: + app: {{ include "event_ingester.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/executor/templates/deployment.yaml b/deployment/executor/templates/deployment.yaml index 1694a53a4d7..abd30ade56f 100644 --- a/deployment/executor/templates/deployment.yaml +++ b/deployment/executor/templates/deployment.yaml @@ -55,7 +55,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} volumeMounts: - name: user-config diff --git a/deployment/executor/templates/profiling-ingress.yaml b/deployment/executor/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..f86ee1119f3 --- /dev/null +++ b/deployment/executor/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "executor.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "executor.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "executor.name" $root }}-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "executor.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/executor/templates/profiling-service.yaml b/deployment/executor/templates/profiling-service.yaml new file mode 100644 index 00000000000..42fe957da66 --- /dev/null +++ b/deployment/executor/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "executor.name" . }}-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "executor.labels.all" . | nindent 4 }} + name: {{ include "executor.name" . }}-profiling +spec: + selector: + app: {{ include "executor.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/lookout-ingester-v2/templates/deployment.yaml b/deployment/lookout-ingester-v2/templates/deployment.yaml index efe46d88554..5d4449564dd 100644 --- a/deployment/lookout-ingester-v2/templates/deployment.yaml +++ b/deployment/lookout-ingester-v2/templates/deployment.yaml @@ -48,7 +48,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} - containerPort: {{ .Values.applicationConfig.metricsPort }} protocol: TCP diff --git a/deployment/lookout-ingester-v2/templates/profiling-ingress.yaml b/deployment/lookout-ingester-v2/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..2cc39735155 --- /dev/null +++ b/deployment/lookout-ingester-v2/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "lookout_ingester_v2.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "lookout_ingester_v2.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "lookout_ingester_v2.name" $root }}-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "lookout_ingester_v2.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/lookout-ingester-v2/templates/profiling-service.yaml b/deployment/lookout-ingester-v2/templates/profiling-service.yaml new file mode 100644 index 00000000000..41a9d2121c0 --- /dev/null +++ b/deployment/lookout-ingester-v2/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "lookout_ingester_v2.name" . }}-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "lookout_ingester_v2.labels.all" . | nindent 4 }} + name: {{ include "lookout_ingester_v2.name" . }}-profiling +spec: + selector: + app: {{ include "lookout_ingester_v2.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/lookout-v2/templates/deployment.yaml b/deployment/lookout-v2/templates/deployment.yaml index f97d9f9ae8b..37aed4fff0c 100644 --- a/deployment/lookout-v2/templates/deployment.yaml +++ b/deployment/lookout-v2/templates/deployment.yaml @@ -51,7 +51,7 @@ spec: {{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} - containerPort: {{ .Values.applicationConfig.profiling.port }} protocol: TCP - name: pprof + name: profiling {{- end }} - containerPort: {{ .Values.applicationConfig.metricsPort }} protocol: TCP diff --git a/deployment/lookout-v2/templates/profiling-ingress.yaml b/deployment/lookout-v2/templates/profiling-ingress.yaml new file mode 100644 index 00000000000..91ce1afaac3 --- /dev/null +++ b/deployment/lookout-v2/templates/profiling-ingress.yaml @@ -0,0 +1,35 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.hostnames }} +{{- $root := . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "lookout_v2.name" . }}-profiling + namespace: {{ .Release.Namespace }} + annotations: + certmanager.k8s.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ required "A value is required for .Values.applicationConfig.profiling.clusterIssuer" .Values.applicationConfig.profiling.clusterIssuer }} + labels: + {{- include "lookout_v2.labels.all" . | nindent 4 }} +spec: + rules: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "lookout_v2.name" $root }}-profiling + port: + number: {{ $root.Values.applicationConfig.profiling.port }} + {{ end -}} + tls: + - hosts: + {{- range required "A value is required for .Values.applicationConfig.profiling.hostnames" .Values.applicationConfig.profiling.hostnames }} + - {{ . -}} + {{ end }} + secretName: {{ include "lookout_v2.name" $root }}-profiling-service-tls +--- +{{- end }} + diff --git a/deployment/lookout-v2/templates/profiling-service.yaml b/deployment/lookout-v2/templates/profiling-service.yaml new file mode 100644 index 00000000000..2cab97e6c1c --- /dev/null +++ b/deployment/lookout-v2/templates/profiling-service.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.applicationConfig.profiling .Values.applicationConfig.profiling.port }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "lookout_v2.name" . }}-profiling + namespace: {{ .Release.Namespace }} + labels: + {{- include "lookout_v2.labels.all" . | nindent 4 }} + name: {{ include "lookout_v2.name" . }}-profiling +spec: + selector: + app: {{ include "lookout_v2.name" . }} + ports: + - name: profiling + protocol: TCP + port: {{ .Values.applicationConfig.profiling.port }} +--- +{{- end }} + diff --git a/deployment/scheduler/templates/scheduler-ingester-profiling-service.yaml b/deployment/scheduler/templates/scheduler-ingester-profiling-service.yaml index 6fd27f0d89b..5ee74583a49 100644 --- a/deployment/scheduler/templates/scheduler-ingester-profiling-service.yaml +++ b/deployment/scheduler/templates/scheduler-ingester-profiling-service.yaml @@ -10,7 +10,6 @@ metadata: spec: selector: app: {{ include "armada-scheduler.name" . }}-ingester - {{- include "armada-scheduler-ingester.labels.all" . | nindent 4 }} ports: - name: profiling protocol: TCP diff --git a/deployment/scheduler/templates/scheduler-profiling-service.yaml b/deployment/scheduler/templates/scheduler-profiling-service.yaml index 51b665f2940..77e30c396ad 100644 --- a/deployment/scheduler/templates/scheduler-profiling-service.yaml +++ b/deployment/scheduler/templates/scheduler-profiling-service.yaml @@ -12,7 +12,6 @@ metadata: spec: selector: statefulset.kubernetes.io/pod-name: {{ include "armada-scheduler.name" $root }}-{{ $i }} - {{- include "armada-scheduler.labels.identity" $root | nindent 4 }} ports: - name: profiling protocol: TCP diff --git a/docs/developer/pprof.md b/docs/developer/pprof.md index 6033f73d69e..dfd2117b74b 100644 --- a/docs/developer/pprof.md +++ b/docs/developer/pprof.md @@ -14,6 +14,5 @@ pprof: ["everyone"] ``` - It's possible to put pprof behind auth, see [api.md#authentication](./api.md#authentication) and [oidc.md](./oidc.md). -- For the scheduler, the helm chart will make a service and ingress for every pod. These are named `armada-scheduler-0-profiling` etc. -- For the scheduler ingester, the helm chart will make a single service and ingress called `armada-scheduler-ingester-profiling`. Note calls to these may not consistently go to the same pod. Use `kubectl port-forward`, or scale the deployment to size 1, if you need to consistently target one pod. -- For other services, the helm charts do not currently expose the profiling port. You can use `kubectl port-forward` to access these. +- For the Armada scheduler, the helm chart will make a service and ingress for every pod. These are named `armada-scheduler-0-profiling` etc. +- For other Armada components, the helm chart will make a single service and ingress called `armada--profiling`. Note calls to these may not consistently go to the same pod. Use `kubectl port-forward`, or scale the deployment to size 1, if you need to consistently target one pod. diff --git a/internal/common/profiling/http.go b/internal/common/profiling/http.go index b691ad16893..5557ef190c4 100644 --- a/internal/common/profiling/http.go +++ b/internal/common/profiling/http.go @@ -23,6 +23,10 @@ func SetupPprof(config *configuration.ProfilingConfig, ctx *armadacontext.Contex } log.Infof("Setting up pprof server on port %d", config.Port) + if config.Auth == nil { + log.Errorf("Pprof server auth not configured, will not set up pprof") + return nil + } authServices, err := auth.ConfigureAuth(*config.Auth) if err != nil { @@ -48,15 +52,18 @@ func SetupPprof(config *configuration.ProfilingConfig, ctx *armadacontext.Contex return ctx, authorizer.AuthorizeAction(armadacontext.FromGrpcCtx(ctx), "pprof") }) + serveFunc := func() error { + if err := serve.ListenAndServe(ctx, pprofServer); err != nil { + logging.WithStacktrace(ctx, err).Error("pprof server failure") + } + return err + } + if g != nil { - g.Go(func() error { - return serve.ListenAndServe(ctx, pprofServer) - }) + g.Go(serveFunc) } else { go func() { - if err := serve.ListenAndServe(ctx, pprofServer); err != nil { - logging.WithStacktrace(ctx, err).Error("pprof server failure") - } + _ = serveFunc() }() } return nil