From 921b20c249240ec271d410bd4531c41272b9c505 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Wed, 26 Nov 2025 17:54:34 +0100 Subject: [PATCH] feat: add `pprof-server` support (#538) Closes #421 Signed-off-by: Armando Ruocco --- .wordlist.txt | 1 + internal/cmd/instance/main.go | 7 +++++++ internal/cnpgi/instance/manager.go | 3 ++- web/docs/misc.md | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.wordlist.txt b/.wordlist.txt index 24d9309..246e667 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -128,6 +128,7 @@ pluginConfiguration podName postgres postgresql +pprof primaryUpdateStrategy rbac rc diff --git a/internal/cmd/instance/main.go b/internal/cmd/instance/main.go index da73385..10a2a8c 100644 --- a/internal/cmd/instance/main.go +++ b/internal/cmd/instance/main.go @@ -52,6 +52,13 @@ func NewCmd() *cobra.Command { }, } + cmd.Flags().String("pprof-server", + "", + "The address where pprof server should be exposed, for example: 0.0.0.0:6061. "+ + "Empty string means disabled. Disabled by default", + ) + _ = viper.BindPFlag("pprof-server", cmd.Flags().Lookup("pprof-server")) + _ = viper.BindEnv("namespace", "NAMESPACE") _ = viper.BindEnv("cluster-name", "CLUSTER_NAME") _ = viper.BindEnv("pod-name", "POD_NAME") diff --git a/internal/cnpgi/instance/manager.go b/internal/cnpgi/instance/manager.go index 450eade..6f82c4c 100644 --- a/internal/cnpgi/instance/manager.go +++ b/internal/cnpgi/instance/manager.go @@ -52,7 +52,8 @@ func Start(ctx context.Context) error { namespace := viper.GetString("namespace") controllerOptions := ctrl.Options{ - Scheme: scheme, + PprofBindAddress: viper.GetString("pprof-server"), + Scheme: scheme, Client: client.Options{ // Important: the caching options below are used by // controller-runtime only. diff --git a/web/docs/misc.md b/web/docs/misc.md index 168ff29..0f03b28 100644 --- a/web/docs/misc.md +++ b/web/docs/misc.md @@ -74,3 +74,24 @@ spec: For a complete list of supported options, refer to the [official Barman Cloud documentation](https://docs.pgbarman.org/release/latest/). + +## Enable the pprof debug server for the sidecar + +You can enable the instance sidecar's pprof debug HTTP server by adding the `--pprof-server=
` flag to the container's +arguments via `.spec.instanceSidecarConfiguration.additionalContainerArgs`. + +Pass a bind address in the form `:` (for example, `0.0.0.0:6061`). +An empty value disables the server (disabled by default). + +### Example + +```yaml +apiVersion: barmancloud.cnpg.io/v1 +kind: ObjectStore +metadata: + name: my-store +spec: + instanceSidecarConfiguration: + additionalContainerArgs: + - "--pprof-server=0.0.0.0:6061" +```