Skip to content

Commit

Permalink
Don't run backup cleanup more often if it fails
Browse files Browse the repository at this point in the history
We update the last-run timestamp before running cleanup, so that
we don't retry immediately if the cleanup fails.

Issue kubernetes-sigs#18
  • Loading branch information
justinsb committed Dec 27, 2024
1 parent ecdaeff commit 890785f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/backupcontroller/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -183,7 +187,5 @@ func (m *BackupCleanup) MaybeDoBackupMaintenance(ctx context.Context) error {
klog.Infof("Removed %d old backups", removedCount)
}

m.lastBackupCleanup = now

return nil
}

0 comments on commit 890785f

Please sign in to comment.