Skip to content

Commit

Permalink
add max retry
Browse files Browse the repository at this point in the history
  • Loading branch information
RidRisR committed Jan 7, 2025
1 parent 8fc3da2 commit 6e12192
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/controller/compactbackup/compact_backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,11 @@ func (c *Controller) allowCompact(compact *v1alpha1.CompactBackup) bool {
}

attempts := len(compact.Status.RetryStatus)
if attempts > 0 && attempts <= int(compact.Spec.MaxRetryTimes) {
if attempts > 0 {
lastRetry := compact.Status.RetryStatus[attempts-1]
if lastRetry.RetryNum >= int(compact.Spec.MaxRetryTimes) {
return false
}
backoff := expBackoff(attempts)
if time.Since(lastRetry.DetectFailedAt.Time) < backoff {
klog.Infof("Compact: [%s/%s] backoff in effect, skipping retry.", ns, name)
Expand Down

0 comments on commit 6e12192

Please sign in to comment.