chore: rename RetentionPolicyRunnable -> CatalogMaintenanceRunnable

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
This commit is contained in:
Armando Ruocco 2025-03-18 16:54:46 +01:00
parent 58ed08e8ee
commit c988b3a052
2 changed files with 15 additions and 11 deletions

View File

@ -66,7 +66,7 @@ func Start(ctx context.Context) error {
return err return err
} }
if err := mgr.Add(&RetentionPolicyRunnable{ if err := mgr.Add(&CatalogMaintenanceRunnable{
Client: customCacheClient, Client: customCacheClient,
Recorder: mgr.GetEventRecorderFor("policy-runnable"), Recorder: mgr.GetEventRecorderFor("policy-runnable"),
ClusterKey: types.NamespacedName{ ClusterKey: types.NamespacedName{

View File

@ -29,9 +29,8 @@ import (
// be read or when the enforcement process failed // be read or when the enforcement process failed
const defaultRetentionPolicyInterval = time.Minute * 5 const defaultRetentionPolicyInterval = time.Minute * 5
// RetentionPolicyRunnable executes the retention policy described // CatalogMaintenanceRunnable executes all the barman catalog maintenance operations
// in the BarmanObjectStore object periodically. type CatalogMaintenanceRunnable struct {
type RetentionPolicyRunnable struct {
Client client.Client Client client.Client
Recorder record.EventRecorder Recorder record.EventRecorder
ClusterKey types.NamespacedName ClusterKey types.NamespacedName
@ -40,7 +39,7 @@ type RetentionPolicyRunnable struct {
// Start enforces the backup retention policies periodically, using the // Start enforces the backup retention policies periodically, using the
// period specified in the BarmanObjectStore object // period specified in the BarmanObjectStore object
func (c *RetentionPolicyRunnable) Start(ctx context.Context) error { func (c *CatalogMaintenanceRunnable) Start(ctx context.Context) error {
contextLogger := log.FromContext(ctx) contextLogger := log.FromContext(ctx)
contextLogger.Info("Starting retention policy runnable") contextLogger.Info("Starting retention policy runnable")
@ -65,7 +64,7 @@ func (c *RetentionPolicyRunnable) 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 *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, error) { func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
var cluster cnpgv1.Cluster var cluster cnpgv1.Cluster
var barmanObjectStore barmancloudv1.ObjectStore var barmanObjectStore barmancloudv1.ObjectStore
@ -78,7 +77,7 @@ func (c *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, err
return 0, err return 0, err
} }
if err := c.applyRetentionPolicy(ctx, &cluster, &barmanObjectStore); err != nil { if err := c.maintenance(ctx, &cluster, &barmanObjectStore); err != nil {
return 0, err return 0, err
} }
@ -87,9 +86,14 @@ func (c *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, err
return nextCheckInterval, nil return nextCheckInterval, nil
} }
// applyRetentionPolicy applies the retention policy to the object // maintenance executes a collection of operations:
// store and deletes the stale Kubernetes backup objects. //
func (c *RetentionPolicyRunnable) applyRetentionPolicy( // - applies the retention policy to the object.
//
// - store and deletes the stale Kubernetes backup objects.
//
// - updates the first recoverability point.
func (c *CatalogMaintenanceRunnable) maintenance(
ctx context.Context, ctx context.Context,
cluster *cnpgv1.Cluster, cluster *cnpgv1.Cluster,
objectStore *barmancloudv1.ObjectStore, objectStore *barmancloudv1.ObjectStore,
@ -156,7 +160,7 @@ func (c *RetentionPolicyRunnable) applyRetentionPolicy(
// updateRecoveryWindow updates the recovery window inside the object // updateRecoveryWindow updates the recovery window inside the object
// store status subresource // store status subresource
func (c *RetentionPolicyRunnable) updateRecoveryWindow( func (c *CatalogMaintenanceRunnable) updateRecoveryWindow(
ctx context.Context, ctx context.Context,
backupList *catalog.Catalog, backupList *catalog.Catalog,
objectStore *barmancloudv1.ObjectStore, objectStore *barmancloudv1.ObjectStore,