From 6005cb2532788933ae1e5a777c21f3f6b25accfa Mon Sep 17 00:00:00 2001 From: Gabriele Fedi Date: Fri, 3 Apr 2026 18:06:55 +0200 Subject: [PATCH 1/3] 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 372d50ee..2748463c 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 0399754ec83f887a4bc709d9cea4fbd9cc725092 Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Thu, 9 Apr 2026 10:53:32 +0200 Subject: [PATCH 2/3] 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 2748463c..4cc6457a 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 } From 66939e6545c5406f2318319189a7d338e413cbb0 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Thu, 9 Apr 2026 14:28:10 +0200 Subject: [PATCH 3/3] chore: simplify maintenance skip condition Signed-off-by: Marco Nenciarini --- internal/cnpgi/instance/retention.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cnpgi/instance/retention.go b/internal/cnpgi/instance/retention.go index 4cc6457a..41769565 100644 --- a/internal/cnpgi/instance/retention.go +++ b/internal/cnpgi/instance/retention.go @@ -91,8 +91,8 @@ func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, } enabledPlugins := cnpgv1.GetPluginConfigurationEnabledPluginNames(cluster.Spec.Plugins) - if enabledForBackups := slices.Contains(enabledPlugins, metadata.PluginName); !enabledForBackups { - contextLogger.Debug("Skipping maintenance cycle: plugin is configured for restore only") + if !slices.Contains(enabledPlugins, metadata.PluginName) { + contextLogger.Debug("Skipping maintenance cycle: plugin is not enabled for backups") return 0, nil }