diff --git a/.changelog/5225.txt b/.changelog/5225.txt new file mode 100644 index 0000000000..6ae3697e52 --- /dev/null +++ b/.changelog/5225.txt @@ -0,0 +1,3 @@ +```release-note:bug +container: fixed an issue where a node pool created with error (eg. GKE_STOCKOUT) would not be captured in state +``` diff --git a/google-beta/resource_container_node_pool.go b/google-beta/resource_container_node_pool.go index b228808434..e3e6d841fc 100644 --- a/google-beta/resource_container_node_pool.go +++ b/google-beta/resource_container_node_pool.go @@ -393,9 +393,14 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e default: // leaving default case to ensure this is non blocking } - // The resource didn't actually create - d.SetId("") - return waitErr + // Check if resource was created but apply timed out. + // Common cause for that is GCE_STOCKOUT which will wait for resources and return error after timeout, + // but in fact nodepool will be created so we have to capture that in state. + _, err = clusterNodePoolsGetCall.Do() + if err != nil { + d.SetId("") + return waitErr + } } log.Printf("[INFO] GKE NodePool %s has been created", nodePool.Name)