From 890785faf97f7698b438f28d8e85c611e7f938ca Mon Sep 17 00:00:00 2001 From: justinsb Date: Fri, 27 Dec 2024 12:58:04 -0500 Subject: [PATCH] Don't run backup cleanup more often if it fails We update the last-run timestamp before running cleanup, so that we don't retry immediately if the cleanup fails. Issue #18 --- pkg/backupcontroller/cleanup.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/backupcontroller/cleanup.go b/pkg/backupcontroller/cleanup.go index fe3a1b46..79022ebe 100644 --- a/pkg/backupcontroller/cleanup.go +++ b/pkg/backupcontroller/cleanup.go @@ -106,6 +106,10 @@ func (m *BackupCleanup) MaybeDoBackupMaintenance(ctx context.Context) error { return nil } + // Set the last backup cleanup time before we run the cleanup, + // so that we don't run this again immediately even if the cleanup fails. + m.lastBackupCleanup = now + backupNames, err := m.backupStore.ListBackups() if err != nil { return fmt.Errorf("error listing backups: %v", err) @@ -183,7 +187,5 @@ func (m *BackupCleanup) MaybeDoBackupMaintenance(ctx context.Context) error { klog.Infof("Removed %d old backups", removedCount) } - m.lastBackupCleanup = now - return nil }