Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6334 Node pool destroy retry on retryable error within configured ti… #6335

Merged
merged 1 commit into from
May 27, 2020
Merged
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
27 changes: 16 additions & 11 deletions google/resource_container_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,29 +395,34 @@ func resourceContainerNodePoolDelete(d *schema.ResourceData, meta interface{}) e
mutexKV.Lock(nodePoolInfo.lockKey())
defer mutexKV.Unlock(nodePoolInfo.lockKey())

var op = &containerBeta.Operation{}
var count = 0
err = resource.Retry(30*time.Second, func() *resource.RetryError {
count++
op, err = config.clientContainerBeta.Projects.Locations.
Clusters.NodePools.Delete(nodePoolInfo.fullyQualifiedName(name)).Do()
timeout := d.Timeout(schema.TimeoutDelete)
startTime := time.Now()

var operation *containerBeta.Operation
err = resource.Retry(timeout, func() *resource.RetryError {
operation, err = config.clientContainerBeta.
Projects.Locations.Clusters.NodePools.Delete(nodePoolInfo.fullyQualifiedName(name)).Do()

if err != nil {
return resource.RetryableError(err)
if isFailedPreconditionError(err) {
// We get failed precondition errors if the cluster is updating
// while we try to delete the node pool.
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}

if count == 15 {
return resource.NonRetryableError(fmt.Errorf("Error retrying to delete node pool %s", name))
}
return nil
})

if err != nil {
return fmt.Errorf("Error deleting NodePool: %s", err)
}

timeout -= time.Since(startTime)

// Wait until it's deleted
waitErr := containerOperationWait(config, op, nodePoolInfo.project, nodePoolInfo.location, "deleting GKE NodePool", d.Timeout(schema.TimeoutDelete))
waitErr := containerOperationWait(config, operation, nodePoolInfo.project, nodePoolInfo.location, "deleting GKE NodePool", timeout)
if waitErr != nil {
return waitErr
}
Expand Down