Skip to content

Commit 63a67cb

Browse files
GabriFedi97leonardocemnencia
authored
fix: skip maintenance cycle when plugin is not enabled for backups (#826)
Skip the catalog maintenance cycle when the plugin is not configured for backups on the cluster, which happens when the plugin is used for restore only. Closes #774 Signed-off-by: Gabriele Fedi <gabriele.fedi@enterprisedb.com> Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 3549e26 commit 63a67cb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/cnpgi/instance/retention.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,26 @@ func (c *CatalogMaintenanceRunnable) Start(ctx context.Context) error {
8181
// cycle enforces the retention policies. On success, it returns the amount
8282
// of time to wait to the next check.
8383
func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
84+
contextLogger := log.FromContext(ctx)
85+
8486
var cluster cnpgv1.Cluster
8587
var barmanObjectStore barmancloudv1.ObjectStore
8688

8789
if err := c.Client.Get(ctx, c.ClusterKey, &cluster); err != nil {
8890
return 0, err
8991
}
9092

93+
enabledPlugins := cnpgv1.GetPluginConfigurationEnabledPluginNames(cluster.Spec.Plugins)
94+
if !slices.Contains(enabledPlugins, metadata.PluginName) {
95+
contextLogger.Debug("Skipping maintenance cycle: plugin is not enabled for backups")
96+
return 0, nil
97+
}
98+
9199
configuration := config.NewFromCluster(&cluster)
100+
if configuration == nil || len(configuration.BarmanObjectName) == 0 {
101+
return 0, fmt.Errorf("invalid configuration, missing barman object store reference")
102+
}
103+
92104
if err := c.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
93105
return 0, err
94106
}

0 commit comments

Comments
 (0)