Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/cnpgi/instance/retention.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,29 @@ 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

if err := c.Client.Get(ctx, c.ClusterKey, &cluster); err != nil {
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
}
Expand Down