Skip to content

Commit

Permalink
Don't clear cluster from state if cleanup fails
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst committed Jul 10, 2019
1 parent ee340d3 commit 344fadd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1092,23 +1092,23 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
d.SetId(clusterName)

// Wait until it's created
timeoutInMinutes := int(d.Timeout(schema.TimeoutCreate).Minutes())
waitErr := containerOperationWait(config, op, project, location, "creating GKE cluster", timeoutInMinutes)
if waitErr != nil {
// Try a GET on the cluster so we can see the state in debug logs. This will help classify error states.
_, getErr := config.clientContainerBeta.Projects.Locations.Clusters.Get(containerClusterFullName(project, location, clusterName)).Do()
if getErr != nil {
// Make errcheck happy
log.Printf("[WARN] Cluster %s was created in an error state and not found", clusterName)
log.Printf("[WARN] Cluster %s was created in an error state and not found", clusterName)
d.SetId("")
}

if deleteErr := cleanFailedContainerCluster(d, meta); deleteErr != nil {
log.Printf("[WARN] Unable to clean up cluster from failed creation: %s", deleteErr)
// Leave ID set as the cluster likely still exists and should not be removed from state yet.
} else {
log.Printf("[WARN] Verified failed creation of cluster %s was cleaned up", d.Id())
d.SetId("")
}
// The resource didn't actually create
d.SetId("")
return waitErr
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ func nodePoolUpdate(d *schema.ResourceData, meta interface{}, nodePoolInfo *Node
}

// Wait until it's updated
timeoutInMinutes := int(d.Timeout(schema.TimeoutCreate).Minutes())
return containerOperationWait(config, op,
nodePoolInfo.project,
nodePoolInfo.location, "updating GKE node pool",
Expand Down

0 comments on commit 344fadd

Please sign in to comment.