From 55ef37fe3897925f2173086c621f9624fed7b9c0 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 8 Apr 2019 16:37:49 -0700 Subject: [PATCH] GET clusters in error states so we see state information in debug logs. (#3389) Original Author: @rileykarson --- google/resource_container_cluster.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index 24af4511..18758625 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -777,6 +777,13 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er 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) + } + if deleteErr := cleanFailedContainerCluster(d, meta); deleteErr != nil { log.Printf("[WARN] Unable to clean up cluster from failed creation: %s", deleteErr) } else {