mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-07-06 17:52:21 +02:00
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>
This commit is contained in:
parent
3549e2650a
commit
63a67cb920
@ -81,6 +81,8 @@ func (c *CatalogMaintenanceRunnable) Start(ctx context.Context) error {
|
|||||||
// cycle enforces the retention policies. On success, it returns the amount
|
// cycle enforces the retention policies. On success, it returns the amount
|
||||||
// of time to wait to the next check.
|
// of time to wait to the next check.
|
||||||
func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
|
func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
|
||||||
|
contextLogger := log.FromContext(ctx)
|
||||||
|
|
||||||
var cluster cnpgv1.Cluster
|
var cluster cnpgv1.Cluster
|
||||||
var barmanObjectStore barmancloudv1.ObjectStore
|
var barmanObjectStore barmancloudv1.ObjectStore
|
||||||
|
|
||||||
@ -88,7 +90,17 @@ func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration,
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabledPlugins := cnpgv1.GetPluginConfigurationEnabledPluginNames(cluster.Spec.Plugins)
|
||||||
|
if !slices.Contains(enabledPlugins, metadata.PluginName) {
|
||||||
|
contextLogger.Debug("Skipping maintenance cycle: plugin is not enabled for backups")
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
configuration := config.NewFromCluster(&cluster)
|
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 {
|
if err := c.Client.Get(ctx, configuration.GetBarmanObjectKey(), &barmanObjectStore); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user