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 <gabriele.fedi@enterprisedb.com>
This commit is contained in:
Gabriele Fedi 2026-04-03 18:06:55 +02:00 committed by Marco Nenciarini
parent e8655233d6
commit 6005cb2532
No known key found for this signature in database
GPG Key ID: 589F03F01BA55038

View File

@ -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
}