Skip to content

Commit 0be4252

Browse files
sl1pm4tdanawillow
authored andcommitted
Fix error if container_node_pool deleted out of band (#293)
Prior to this change it was possible for Terraform to error during plan / apply with the following: Error 404: The resource "node pool \"foo\" not found"
1 parent dd93516 commit 0be4252

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

google/resource_container_node_pool.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/hashicorp/terraform/helper/resource"
88
"github.com/hashicorp/terraform/helper/schema"
99
"google.golang.org/api/container/v1"
10-
"google.golang.org/api/googleapi"
1110
)
1211

1312
func resourceContainerNodePool() *schema.Resource {
@@ -350,10 +349,8 @@ func resourceContainerNodePoolExists(d *schema.ResourceData, meta interface{}) (
350349
_, err = config.clientContainer.Projects.Zones.Clusters.NodePools.Get(
351350
project, zone, cluster, name).Do()
352351
if err != nil {
353-
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 {
354-
log.Printf("[WARN] Removing Container NodePool %q because it's gone", name)
355-
// The resource doesn't exist anymore
356-
return false, err
352+
if err = handleNotFoundError(err, d, fmt.Sprintf("Container NodePool %s", d.Get("name").(string))); err == nil {
353+
return false, nil
357354
}
358355
// There was some other error in reading the resource
359356
return true, err

0 commit comments

Comments
 (0)