Skip to content

Commit c988b3a

Browse files
committed
chore: rename RetentionPolicyRunnable -> CatalogMaintenanceRunnable
Signed-off-by: Armando Ruocco <[email protected]>
1 parent 58ed08e commit c988b3a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

internal/cnpgi/instance/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Start(ctx context.Context) error {
6666
return err
6767
}
6868

69-
if err := mgr.Add(&RetentionPolicyRunnable{
69+
if err := mgr.Add(&CatalogMaintenanceRunnable{
7070
Client: customCacheClient,
7171
Recorder: mgr.GetEventRecorderFor("policy-runnable"),
7272
ClusterKey: types.NamespacedName{

internal/cnpgi/instance/retention.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ import (
2929
// be read or when the enforcement process failed
3030
const defaultRetentionPolicyInterval = time.Minute * 5
3131

32-
// RetentionPolicyRunnable executes the retention policy described
33-
// in the BarmanObjectStore object periodically.
34-
type RetentionPolicyRunnable struct {
32+
// CatalogMaintenanceRunnable executes all the barman catalog maintenance operations
33+
type CatalogMaintenanceRunnable struct {
3534
Client client.Client
3635
Recorder record.EventRecorder
3736
ClusterKey types.NamespacedName
@@ -40,7 +39,7 @@ type RetentionPolicyRunnable struct {
4039

4140
// Start enforces the backup retention policies periodically, using the
4241
// period specified in the BarmanObjectStore object
43-
func (c *RetentionPolicyRunnable) Start(ctx context.Context) error {
42+
func (c *CatalogMaintenanceRunnable) Start(ctx context.Context) error {
4443
contextLogger := log.FromContext(ctx)
4544
contextLogger.Info("Starting retention policy runnable")
4645

@@ -65,7 +64,7 @@ func (c *RetentionPolicyRunnable) Start(ctx context.Context) error {
6564

6665
// cycle enforces the retention policies. On success, it returns the amount
6766
// of time to wait to the next check.
68-
func (c *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, error) {
67+
func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
6968
var cluster cnpgv1.Cluster
7069
var barmanObjectStore barmancloudv1.ObjectStore
7170

@@ -78,7 +77,7 @@ func (c *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, err
7877
return 0, err
7978
}
8079

81-
if err := c.applyRetentionPolicy(ctx, &cluster, &barmanObjectStore); err != nil {
80+
if err := c.maintenance(ctx, &cluster, &barmanObjectStore); err != nil {
8281
return 0, err
8382
}
8483

@@ -87,9 +86,14 @@ func (c *RetentionPolicyRunnable) cycle(ctx context.Context) (time.Duration, err
8786
return nextCheckInterval, nil
8887
}
8988

90-
// applyRetentionPolicy applies the retention policy to the object
91-
// store and deletes the stale Kubernetes backup objects.
92-
func (c *RetentionPolicyRunnable) applyRetentionPolicy(
89+
// maintenance executes a collection of operations:
90+
//
91+
// - applies the retention policy to the object.
92+
//
93+
// - store and deletes the stale Kubernetes backup objects.
94+
//
95+
// - updates the first recoverability point.
96+
func (c *CatalogMaintenanceRunnable) maintenance(
9397
ctx context.Context,
9498
cluster *cnpgv1.Cluster,
9599
objectStore *barmancloudv1.ObjectStore,
@@ -156,7 +160,7 @@ func (c *RetentionPolicyRunnable) applyRetentionPolicy(
156160

157161
// updateRecoveryWindow updates the recovery window inside the object
158162
// store status subresource
159-
func (c *RetentionPolicyRunnable) updateRecoveryWindow(
163+
func (c *CatalogMaintenanceRunnable) updateRecoveryWindow(
160164
ctx context.Context,
161165
backupList *catalog.Catalog,
162166
objectStore *barmancloudv1.ObjectStore,

0 commit comments

Comments
 (0)