Skip to content

Commit 6d672ea

Browse files
authored
Merge pull request #6266 from ykakarap/retry-delete-during-upgrade
🐛 retry delete during clusterctl upgrade
2 parents e59c785 + a58e97c commit 6d672ea

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cmd/clusterctl/client/cluster/components.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,18 @@ func (p *providerComponents) Delete(options DeleteOptions) error {
212212

213213
// Otherwise delete the object
214214
log.V(5).Info("Deleting", logf.UnstructuredToValues(obj)...)
215-
if err := cs.Delete(ctx, &obj); err != nil {
216-
if apierrors.IsNotFound(err) {
217-
// Tolerate IsNotFound error that might happen because we are not enforcing a deletion order
218-
// that considers relation across objects (e.g. Deployments -> ReplicaSets -> Pods)
219-
continue
215+
deleteBackoff := newWriteBackoff()
216+
if err := retryWithExponentialBackoff(deleteBackoff, func() error {
217+
if err := cs.Delete(ctx, &obj); err != nil {
218+
if apierrors.IsNotFound(err) {
219+
// Tolerate IsNotFound error that might happen because we are not enforcing a deletion order
220+
// that considers relation across objects (e.g. Deployments -> ReplicaSets -> Pods)
221+
return nil
222+
}
223+
return err
220224
}
225+
return nil
226+
}); err != nil {
221227
errList = append(errList, errors.Wrapf(err, "Error deleting object %s, %s/%s", obj.GroupVersionKind(), obj.GetNamespace(), obj.GetName()))
222228
}
223229
}

0 commit comments

Comments
 (0)