Skip to content

Commit

Permalink
Fix error if container_node_pool deleted out of band (hashicorp#293)
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
sl1pm4t authored and Dmitry Vlasov committed Aug 15, 2017
1 parent 60119a4 commit 22031db
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions google/resource_container_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/container/v1"
"google.golang.org/api/googleapi"
)

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

0 comments on commit 22031db

Please sign in to comment.