Sitelet https://github.com/kubernetes/kops/commit/19f7a57520cfa4bca74dc0d3c00bcbe71cac30a0
Skip to content

Commit 19f7a57

Browse files
Merge pull request #18595 from hakman/delete-cluster-retry-listing
fix: retry listing cloud resources in `kops delete cluster`
2 parents 179f18b + b759c16 commit 19f7a57

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎cmd/kops/delete_cluster.go‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,20 @@ func RunDeleteCluster(ctx context.Context, f *util.Factory, out io.Writer, optio
141141
}
142142

143143
klog.Info("Looking for cloud resources to delete")
144-
allResources, err := resourceops.ListResources(cloud, cluster)
145-
if err != nil {
146-
return err
144+
// Listing resources involves many cloud API calls; not all cloud SDKs retry transient errors
145+
// (e.g. GCE 5xx), and a single failed call would otherwise abort the deletion. Retry a few
146+
// times before giving up.
147+
var allResources map[string]*resources.Resource
148+
for attempt := 1; ; attempt++ {
149+
allResources, err = resourceops.ListResources(cloud, cluster)
150+
if err == nil {
151+
break
152+
}
153+
if attempt >= 4 {
154+
return err
155+
}
156+
klog.Warningf("error listing cloud resources, will retry: %v", err)
157+
time.Sleep(options.interval)
147158
}
148159

149160
clusterResources := make(map[string]*resources.Resource)

0 commit comments

Comments
 (0)