mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
feat: add pprof
This patch adds the pprof server feature to the instance sidecar container Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
This commit is contained in:
parent
8901cb94f9
commit
1003a3e6a7
@ -128,6 +128,7 @@ pluginConfiguration
|
|||||||
podName
|
podName
|
||||||
postgres
|
postgres
|
||||||
postgresql
|
postgresql
|
||||||
|
pprof
|
||||||
primaryUpdateStrategy
|
primaryUpdateStrategy
|
||||||
rbac
|
rbac
|
||||||
rc
|
rc
|
||||||
|
|||||||
@ -52,6 +52,12 @@ func NewCmd() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Flags().Bool("pprof-server",
|
||||||
|
false,
|
||||||
|
"If true it will start a pprof debug http server on localhost:6061. Defaults to false.",
|
||||||
|
)
|
||||||
|
_ = viper.BindPFlag("pprof-server", cmd.Flags().Lookup("pprof-server"))
|
||||||
|
|
||||||
_ = viper.BindEnv("namespace", "NAMESPACE")
|
_ = viper.BindEnv("namespace", "NAMESPACE")
|
||||||
_ = viper.BindEnv("cluster-name", "CLUSTER_NAME")
|
_ = viper.BindEnv("cluster-name", "CLUSTER_NAME")
|
||||||
_ = viper.BindEnv("pod-name", "POD_NAME")
|
_ = viper.BindEnv("pod-name", "POD_NAME")
|
||||||
|
|||||||
@ -52,7 +52,8 @@ func Start(ctx context.Context) error {
|
|||||||
namespace := viper.GetString("namespace")
|
namespace := viper.GetString("namespace")
|
||||||
|
|
||||||
controllerOptions := ctrl.Options{
|
controllerOptions := ctrl.Options{
|
||||||
Scheme: scheme,
|
PprofBindAddress: getPprofServerAddress(),
|
||||||
|
Scheme: scheme,
|
||||||
Client: client.Options{
|
Client: client.Options{
|
||||||
// Important: the caching options below are used by
|
// Important: the caching options below are used by
|
||||||
// controller-runtime only.
|
// controller-runtime only.
|
||||||
@ -148,3 +149,11 @@ func generateScheme(ctx context.Context) *runtime.Scheme {
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPprofServerAddress() string {
|
||||||
|
if viper.GetBool("pprof-server") {
|
||||||
|
return "0.0.0.0:6061"
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|||||||
@ -74,3 +74,23 @@ spec:
|
|||||||
|
|
||||||
For a complete list of supported options, refer to the
|
For a complete list of supported options, refer to the
|
||||||
[official Barman Cloud documentation](https://docs.pgbarman.org/release/latest/).
|
[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` in the `ObjectStore` resource.
|
||||||
|
|
||||||
|
This starts a pprof server on port 6061 inside the Pod.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: barmancloud.cnpg.io/v1
|
||||||
|
kind: ObjectStore
|
||||||
|
metadata:
|
||||||
|
name: my-store
|
||||||
|
spec:
|
||||||
|
instanceSidecarConfiguration:
|
||||||
|
additionalContainerArgs:
|
||||||
|
- "--pprof-server"
|
||||||
|
```
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user