Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion controllers/providers/kubernetes/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func ProcessCRDStrategy(kube dynamic.Interface, instanceGroup *v1alpha1.Instance
return false, errors.Wrap(err, "failed to discover active custom resources")
}

// didReplace tracks whether we deleted a failed/stale CR on this pass.
// When we replace, the retry counter must NOT be reset: the retry counter
// exists to bound how many times we replace a failing CR, and resetting
// it on every successful re-create produced an infinite loop (#317).
var didReplace bool
if len(activeResources) > 0 {

switch strings.ToLower(policy) {
Expand Down Expand Up @@ -132,6 +137,7 @@ func ProcessCRDStrategy(kube dynamic.Interface, instanceGroup *v1alpha1.Instance
return false, errors.Wrap(err, "failed to delete custom resource")
}
}
didReplace = true
}
if isRunning {
// finally, if an active resource is still running, requeue until it's done
Expand All @@ -152,7 +158,12 @@ func ProcessCRDStrategy(kube dynamic.Interface, instanceGroup *v1alpha1.Instance
}
} else {
log.Info("submitted custom resource", "instancegroup", instanceGroupNamespacedName)
status.SetStrategyRetryCount(0)
if !didReplace {
// First-time submission for this strategy attempt: safe to clear
// the retry counter. On replace we keep the accumulated count so
// the retry budget is actually enforced.
status.SetStrategyRetryCount(0)
}
}

// get created resource
Expand Down