mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-14 06:33:10 +01:00
Compare commits
1 Commits
df32ec1ce0
...
5cac225e33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cac225e33 |
@ -128,7 +128,6 @@ pluginConfiguration
|
|||||||
podName
|
podName
|
||||||
postgres
|
postgres
|
||||||
postgresql
|
postgresql
|
||||||
pprof
|
|
||||||
primaryUpdateStrategy
|
primaryUpdateStrategy
|
||||||
rbac
|
rbac
|
||||||
rc
|
rc
|
||||||
|
|||||||
@ -52,13 +52,6 @@ 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("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")
|
||||||
|
|||||||
@ -55,7 +55,6 @@ type ExtendedClient struct {
|
|||||||
cachedObjects []cachedEntry
|
cachedObjects []cachedEntry
|
||||||
mux *sync.Mutex
|
mux *sync.Mutex
|
||||||
cleanupInterval time.Duration
|
cleanupInterval time.Duration
|
||||||
cleanupDone chan struct{} // Signals when cleanup routine exits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewExtendedClient returns an extended client capable of caching secrets on the 'Get' operation.
|
// NewExtendedClient returns an extended client capable of caching secrets on the 'Get' operation.
|
||||||
@ -69,7 +68,6 @@ func NewExtendedClient(
|
|||||||
Client: baseClient,
|
Client: baseClient,
|
||||||
mux: &sync.Mutex{},
|
mux: &sync.Mutex{},
|
||||||
cleanupInterval: DefaultCleanupIntervalSeconds * time.Second,
|
cleanupInterval: DefaultCleanupIntervalSeconds * time.Second,
|
||||||
cleanupDone: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the background cleanup routine
|
// Start the background cleanup routine
|
||||||
@ -227,7 +225,6 @@ func (e *ExtendedClient) Patch(
|
|||||||
// startCleanupRoutine periodically removes expired entries from the cache.
|
// startCleanupRoutine periodically removes expired entries from the cache.
|
||||||
// It runs until the context is cancelled.
|
// It runs until the context is cancelled.
|
||||||
func (e *ExtendedClient) startCleanupRoutine(ctx context.Context) {
|
func (e *ExtendedClient) startCleanupRoutine(ctx context.Context) {
|
||||||
defer close(e.cleanupDone)
|
|
||||||
contextLogger := log.FromContext(ctx).WithName("extended_client_cleanup")
|
contextLogger := log.FromContext(ctx).WithName("extended_client_cleanup")
|
||||||
ticker := time.NewTicker(e.cleanupInterval)
|
ticker := time.NewTicker(e.cleanupInterval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|||||||
@ -302,12 +302,10 @@ var _ = Describe("ExtendedClient Cache Cleanup", func() {
|
|||||||
// Cancel the context immediately
|
// Cancel the context immediately
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
// Verify the cleanup routine actually stops by waiting for the done channel
|
// Give the goroutine time to stop
|
||||||
select {
|
time.Sleep(50 * time.Millisecond)
|
||||||
case <-ec.cleanupDone:
|
|
||||||
// Success: cleanup routine exited as expected
|
// The goroutine should have stopped gracefully (no panic or hanging)
|
||||||
case <-time.After(1 * time.Second):
|
// This test mainly verifies the cleanup routine respects context cancellation
|
||||||
Fail("cleanup routine did not stop within timeout")
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -52,8 +52,7 @@ func Start(ctx context.Context) error {
|
|||||||
namespace := viper.GetString("namespace")
|
namespace := viper.GetString("namespace")
|
||||||
|
|
||||||
controllerOptions := ctrl.Options{
|
controllerOptions := ctrl.Options{
|
||||||
PprofBindAddress: viper.GetString("pprof-server"),
|
Scheme: scheme,
|
||||||
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.
|
||||||
|
|||||||
@ -74,24 +74,3 @@ 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=<address>` flag to the container's
|
|
||||||
arguments via `.spec.instanceSidecarConfiguration.additionalContainerArgs`.
|
|
||||||
|
|
||||||
Pass a bind address in the form `<host>:<port>` (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"
|
|
||||||
```
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user