From 43ea991a25444eb9a2e700c379ad2e8233cf6b68 Mon Sep 17 00:00:00 2001 From: Papapetrou Patroklos <1743100+ppapapetrou76@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:16:17 +0200 Subject: [PATCH] fix: register pprof endpoints in repo-server using the params config map (#26237) Signed-off-by: Patroklos Papapetrou --- cmd/argocd-repo-server/commands/argocd_repo_server.go | 9 ++++++--- docs/operator-manual/argocd-cmd-params-cm.yaml | 2 ++ docs/operator-manual/high_availability.md | 8 ++++---- .../base/repo-server/argocd-repo-server-deployment.yaml | 7 +++++++ manifests/core-install-with-hydrator.yaml | 7 +++++++ manifests/core-install.yaml | 7 +++++++ manifests/ha/install-with-hydrator.yaml | 7 +++++++ manifests/ha/install.yaml | 7 +++++++ manifests/ha/namespace-install-with-hydrator.yaml | 7 +++++++ manifests/ha/namespace-install.yaml | 7 +++++++ manifests/install-with-hydrator.yaml | 7 +++++++ manifests/install.yaml | 7 +++++++ manifests/namespace-install-with-hydrator.yaml | 7 +++++++ manifests/namespace-install.yaml | 7 +++++++ 14 files changed, 89 insertions(+), 7 deletions(-) diff --git a/cmd/argocd-repo-server/commands/argocd_repo_server.go b/cmd/argocd-repo-server/commands/argocd_repo_server.go index 5356dfc256..4203aa9a8c 100644 --- a/cmd/argocd-repo-server/commands/argocd_repo_server.go +++ b/cmd/argocd-repo-server/commands/argocd_repo_server.go @@ -34,6 +34,7 @@ import ( "github.com/argoproj/argo-cd/v3/util/gpg" "github.com/argoproj/argo-cd/v3/util/healthz" utilio "github.com/argoproj/argo-cd/v3/util/io" + "github.com/argoproj/argo-cd/v3/util/profile" "github.com/argoproj/argo-cd/v3/util/tls" traceutil "github.com/argoproj/argo-cd/v3/util/trace" ) @@ -177,7 +178,8 @@ func NewCommand() *cobra.Command { listener, err := lc.Listen(ctx, "tcp", fmt.Sprintf("%s:%d", listenHost, listenPort)) errors.CheckError(err) - healthz.ServeHealthCheck(http.DefaultServeMux, func(r *http.Request) error { + mux := http.NewServeMux() + healthz.ServeHealthCheck(mux, func(r *http.Request) error { if val, ok := r.URL.Query()["full"]; ok && len(val) > 0 && val[0] == "true" { // connect to itself to make sure repo server is able to serve connection // used by liveness probe to auto restart repo server @@ -199,8 +201,9 @@ func NewCommand() *cobra.Command { } return nil }) - http.Handle("/metrics", metricsServer.GetHandler()) - go func() { errors.CheckError(http.ListenAndServe(fmt.Sprintf("%s:%d", metricsHost, metricsPort), nil)) }() + mux.Handle("/metrics", metricsServer.GetHandler()) + profile.RegisterProfiler(mux) + go func() { errors.CheckError(http.ListenAndServe(fmt.Sprintf("%s:%d", metricsHost, metricsPort), mux)) }() go func() { errors.CheckError(askPassServer.Run()) }() if gpg.IsGPGEnabled() { diff --git a/docs/operator-manual/argocd-cmd-params-cm.yaml b/docs/operator-manual/argocd-cmd-params-cm.yaml index 581d8242f6..de0f0376da 100644 --- a/docs/operator-manual/argocd-cmd-params-cm.yaml +++ b/docs/operator-manual/argocd-cmd-params-cm.yaml @@ -279,6 +279,8 @@ data: # _grpc_config. are disabled to prevent excessive DNS queries that can cause timeouts in dual-stack environments. # See https://github.com/argoproj/argo-cd/issues/24991 reposerver.grpc.enable.txt.service.config: "false" + # Enables profile endpoint on the internal metrics port + reposerver.profile.enabled: "false" ## Commit-server properties # Listen on given address for incoming connections (default "0.0.0.0") diff --git a/docs/operator-manual/high_availability.md b/docs/operator-manual/high_availability.md index 2ce24a551d..16cb955c6d 100644 --- a/docs/operator-manual/high_availability.md +++ b/docs/operator-manual/high_availability.md @@ -522,12 +522,12 @@ Not all HTTP responses are eligible for retries. The following conditions will n Argo CD optionally exposes a profiling endpoint that can be used to profile the CPU and memory usage of the Argo CD component. -The profiling endpoint is available on metrics port of each component. See [metrics](./metrics.md) for more information +The profiling endpoint is available on the metrics port of each component. See [metrics](./metrics.md) for more information about the port. For security reasons, the profiling endpoint is disabled by default. The endpoint can be enabled by setting the -`server.profile.enabled`, `applicationsetcontroller.profile.enabled`, or `controller.profile.enabled` key -of [argocd-cmd-params-cm](argocd-cmd-params-cm.yaml) ConfigMap to `true`. -Once the endpoint is enabled, you can use go profile tool to collect the CPU and memory profiles. Example: +`server.profile.enabled`, `applicationsetcontroller.profile.enabled`, `reposerver.profile.enabled` or +`controller.profile.enabled` key of [argocd-cmd-params-cm](argocd-cmd-params-cm.yaml) ConfigMap to `true`. +Once the endpoint is enabled, you can use the go profile tool to collect the CPU and memory profiles. Example: ```bash $ kubectl port-forward svc/argocd-metrics 8082:8082 diff --git a/manifests/base/repo-server/argocd-repo-server-deployment.yaml b/manifests/base/repo-server/argocd-repo-server-deployment.yaml index a10f1421bb..13671de53a 100644 --- a/manifests/base/repo-server/argocd-repo-server-deployment.yaml +++ b/manifests/base/repo-server/argocd-repo-server-deployment.yaml @@ -369,6 +369,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - name: argocd-cmd-params-cm + configMap: + optional: true + name: argocd-cmd-params-cm + items: + - key: reposerver.profile.enabled + path: profiler.enabled affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: diff --git a/manifests/core-install-with-hydrator.yaml b/manifests/core-install-with-hydrator.yaml index 83d214f408..b7107b91e2 100644 --- a/manifests/core-install-with-hydrator.yaml +++ b/manifests/core-install-with-hydrator.yaml @@ -32011,6 +32011,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: StatefulSet diff --git a/manifests/core-install.yaml b/manifests/core-install.yaml index f29790ee1e..e8e2141c1c 100644 --- a/manifests/core-install.yaml +++ b/manifests/core-install.yaml @@ -31839,6 +31839,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: StatefulSet diff --git a/manifests/ha/install-with-hydrator.yaml b/manifests/ha/install-with-hydrator.yaml index 28bd768096..a579203ab2 100644 --- a/manifests/ha/install-with-hydrator.yaml +++ b/manifests/ha/install-with-hydrator.yaml @@ -33646,6 +33646,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/ha/install.yaml b/manifests/ha/install.yaml index 65116a0885..50acd99357 100644 --- a/manifests/ha/install.yaml +++ b/manifests/ha/install.yaml @@ -33476,6 +33476,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/ha/namespace-install-with-hydrator.yaml b/manifests/ha/namespace-install-with-hydrator.yaml index 4d4fa19b78..aba76de2f2 100644 --- a/manifests/ha/namespace-install-with-hydrator.yaml +++ b/manifests/ha/namespace-install-with-hydrator.yaml @@ -2893,6 +2893,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/ha/namespace-install.yaml b/manifests/ha/namespace-install.yaml index f34d3bdecd..9d86778c75 100644 --- a/manifests/ha/namespace-install.yaml +++ b/manifests/ha/namespace-install.yaml @@ -2723,6 +2723,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/install-with-hydrator.yaml b/manifests/install-with-hydrator.yaml index 79ea7a1dbf..0b3f507f24 100644 --- a/manifests/install-with-hydrator.yaml +++ b/manifests/install-with-hydrator.yaml @@ -32676,6 +32676,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/install.yaml b/manifests/install.yaml index 4f0e11b020..302fd31e12 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -32504,6 +32504,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/namespace-install-with-hydrator.yaml b/manifests/namespace-install-with-hydrator.yaml index 5399e27ffd..d299e736f8 100644 --- a/manifests/namespace-install-with-hydrator.yaml +++ b/manifests/namespace-install-with-hydrator.yaml @@ -1923,6 +1923,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index 593beba3ff..8394abbc39 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -1751,6 +1751,13 @@ spec: name: var-files - emptyDir: {} name: plugins + - configMap: + items: + - key: reposerver.profile.enabled + path: profiler.enabled + name: argocd-cmd-params-cm + optional: true + name: argocd-cmd-params-cm --- apiVersion: apps/v1 kind: Deployment