From f7544297016ac0fadd6bb7491d946617061795ae Mon Sep 17 00:00:00 2001 From: Gabriele Fedi Date: Fri, 3 Apr 2026 18:06:55 +0200 Subject: [PATCH 1/2] fix: skip maintainance when not required Perform maintenance cycle only when the plugin is enabled for backups and WAL archiving. Signed-off-by: Gabriele Fedi --- internal/cnpgi/instance/retention.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/cnpgi/instance/retention.go b/internal/cnpgi/instance/retention.go index 372d50e..2748463 100644 --- a/internal/cnpgi/instance/retention.go +++ b/internal/cnpgi/instance/retention.go @@ -81,6 +81,8 @@ func (c *CatalogMaintenanceRunnable) Start(ctx context.Context) error { // cycle enforces the retention policies. On success, it returns the amount // of time to wait to the next check. func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) { + contextLogger := log.FromContext(ctx) + var cluster cnpgv1.Cluster var barmanObjectStore barmancloudv1.ObjectStore @@ -88,7 +90,20 @@ func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, return 0, err } + enabledPlugins := cnpgv1.GetPluginConfigurationEnabledPluginNames(cluster.Spec.Plugins) + enabledForBackups := slices.Contains(enabledPlugins, metadata.PluginName) + + if !enabledForBackups { + contextLogger.Debug("Skipping maintenance cycle." + + " Plugin is not enabled for backups") + return 0, nil + } + configuration := config.NewFromCluster(&cluster) + if configuration == nil || len(configuration.BarmanObjectName) == 0 { + return 0, fmt.Errorf("invalid configuration, missing barman object store reference") + } + if err := c.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil { return 0, err } From 125ba292abe7389c4bf9d14a87cd7292657c75cb Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Thu, 9 Apr 2026 10:53:32 +0200 Subject: [PATCH 2/2] chore: nits Signed-off-by: Leonardo Cecchi --- internal/cnpgi/instance/retention.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/cnpgi/instance/retention.go b/internal/cnpgi/instance/retention.go index 2748463..4cc6457 100644 --- a/internal/cnpgi/instance/retention.go +++ b/internal/cnpgi/instance/retention.go @@ -91,11 +91,8 @@ func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, } enabledPlugins := cnpgv1.GetPluginConfigurationEnabledPluginNames(cluster.Spec.Plugins) - enabledForBackups := slices.Contains(enabledPlugins, metadata.PluginName) - - if !enabledForBackups { - contextLogger.Debug("Skipping maintenance cycle." + - " Plugin is not enabled for backups") + if enabledForBackups := slices.Contains(enabledPlugins, metadata.PluginName); !enabledForBackups { + contextLogger.Debug("Skipping maintenance cycle: plugin is configured for restore only") return 0, nil }