Skip to content

Commit 921b20c

Browse files
authored
feat: add pprof-server support (#538)
Closes #421 Signed-off-by: Armando Ruocco <[email protected]>
1 parent 8901cb9 commit 921b20c

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pluginConfiguration
128128
podName
129129
postgres
130130
postgresql
131+
pprof
131132
primaryUpdateStrategy
132133
rbac
133134
rc

internal/cmd/instance/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ func NewCmd() *cobra.Command {
5252
},
5353
}
5454

55+
cmd.Flags().String("pprof-server",
56+
"",
57+
"The address where pprof server should be exposed, for example: 0.0.0.0:6061. "+
58+
"Empty string means disabled. Disabled by default",
59+
)
60+
_ = viper.BindPFlag("pprof-server", cmd.Flags().Lookup("pprof-server"))
61+
5562
_ = viper.BindEnv("namespace", "NAMESPACE")
5663
_ = viper.BindEnv("cluster-name", "CLUSTER_NAME")
5764
_ = viper.BindEnv("pod-name", "POD_NAME")

internal/cnpgi/instance/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func Start(ctx context.Context) error {
5252
namespace := viper.GetString("namespace")
5353

5454
controllerOptions := ctrl.Options{
55-
Scheme: scheme,
55+
PprofBindAddress: viper.GetString("pprof-server"),
56+
Scheme: scheme,
5657
Client: client.Options{
5758
// Important: the caching options below are used by
5859
// controller-runtime only.

web/docs/misc.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,24 @@ spec:
7474
7575
For a complete list of supported options, refer to the
7676
[official Barman Cloud documentation](https://docs.pgbarman.org/release/latest/).
77+
78+
## Enable the pprof debug server for the sidecar
79+
80+
You can enable the instance sidecar's pprof debug HTTP server by adding the `--pprof-server=<address>` flag to the container's
81+
arguments via `.spec.instanceSidecarConfiguration.additionalContainerArgs`.
82+
83+
Pass a bind address in the form `<host>:<port>` (for example, `0.0.0.0:6061`).
84+
An empty value disables the server (disabled by default).
85+
86+
### Example
87+
88+
```yaml
89+
apiVersion: barmancloud.cnpg.io/v1
90+
kind: ObjectStore
91+
metadata:
92+
name: my-store
93+
spec:
94+
instanceSidecarConfiguration:
95+
additionalContainerArgs:
96+
- "--pprof-server=0.0.0.0:6061"
97+
```

0 commit comments

Comments
 (0)