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
35 changes: 29 additions & 6 deletions pkg/destroy/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ func (o *ClusterUninstaller) destroyCluster() (bool, error) {
{name: "Cloud controller resources", execute: o.discoverCloudControllerResources},
}, {
{name: "Instances", execute: o.destroyInstances},
}, {
// LB frontend: forwarding rules reference target TCP proxies and target pools.
{name: "Forwarding rules", execute: o.destroyForwardingRules},
{name: "Target Pools", execute: o.destroyTargetPools},
{name: "Target TCP Proxies", execute: o.destroyTargetTCPProxies},
}, {
// LB backend: backend services reference instance groups and health checks.
{name: "Backend services", execute: o.destroyBackendServices},
{name: "Health checks", execute: o.destroyHealthChecks},
{name: "HTTP Health checks", execute: o.destroyHTTPHealthChecks},
}, {
{name: "Disks", execute: o.destroyDisks},
{name: "Service accounts", execute: o.destroyServiceAccounts},
{name: "Images", execute: o.destroyImages},
Expand All @@ -210,13 +221,7 @@ func (o *ClusterUninstaller) destroyCluster() (bool, error) {
{name: "Routes", execute: o.destroyRoutes},
{name: "Firewalls", execute: o.destroyFirewalls},
{name: "Addresses", execute: o.destroyAddresses},
{name: "Forwarding rules", execute: o.destroyForwardingRules},
{name: "Target Pools", execute: o.destroyTargetPools},
{name: "Instance groups", execute: o.destroyInstanceGroups},
{name: "Target TCP Proxies", execute: o.destroyTargetTCPProxies},
{name: "Backend services", execute: o.destroyBackendServices},
{name: "Health checks", execute: o.destroyHealthChecks},
{name: "HTTP Health checks", execute: o.destroyHTTPHealthChecks},
{name: "Routers", execute: o.destroyRouters},
{name: "Subnetworks", execute: o.destroySubnetworks},
{name: "Networks", execute: o.destroyNetworks},
Expand Down Expand Up @@ -443,6 +448,18 @@ func isErrorStatus(code int64) bool {
return code != 0 && (code < 200 || code >= 300)
}

func hasInternalError(op *compute.Operation) bool {
if op.Error == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if op.Error == nil {
if op == nil || op.Error == nil {

return false
}
for _, e := range op.Error.Errors {
if e.Code == "INTERNAL_ERROR" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if e.Code == "INTERNAL_ERROR" {
if e != nil && e.Code == "INTERNAL_ERROR" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we define "INTERNAL_ERROR" as a const for consistancy?

return true
}
}
return false
}

func operationErrorMessage(op *compute.Operation) string {
errs := []string{}
if op.Error != nil {
Expand Down Expand Up @@ -479,6 +496,12 @@ func (o *ClusterUninstaller) handleOperation(ctx context.Context, op *compute.Op
o.resetRequestID(identifier...)
return fmt.Errorf("failed to delete %s %s with error: %s", resourceType, item.name, operationErrorMessage(op))
}
if op != nil && op.Status != DONE && hasInternalError(op) {
o.resetRequestID(identifier...)
o.errorTracker.suppressWarning(item.key, fmt.Errorf("GCP operation %s for %s %s hit an internal error and will be retried: %s",
op.Name, resourceType, item.name, operationErrorMessage(op)), o.Logger)
return fmt.Errorf("delete %s %s: GCP internal error, retrying", resourceType, item.name)
}
if (err != nil && isNoOp(err)) || (op != nil && op.Status == DONE) {
o.resetRequestID(identifier...)
o.deletePendingItems(item.typeName, []cloudResource{item})
Expand Down