From 7b4e58067d96f42f47dbbca704d0755b049f94be Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 22 Sep 2021 15:52:52 -0500 Subject: [PATCH] Check if nodepool created before returning error (#5225) (#3646) Signed-off-by: Modular Magician --- .changelog/5225.txt | 3 +++ google-beta/resource_container_node_pool.go | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changelog/5225.txt 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)