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 }