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 `