Skip to content

Commit

Permalink
Cause node pool to be written to statefile even if creation fails. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson authored May 6, 2020
1 parent 390ed23 commit 95418fd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e
timeout := d.Timeout(schema.TimeoutCreate)
startTime := time.Now()

// Set the ID before we attempt to create - that way, if we receive an error but
// the resource is created anyway, it will be refreshed on the next call to
// apply.
d.SetId(fmt.Sprintf("projects/%s/locations/%s/clusters/%s/nodePools/%s", nodePoolInfo.project, nodePoolInfo.location, nodePoolInfo.cluster, nodePool.Name))

var operation *containerBeta.Operation
err = resource.Retry(timeout, func() *resource.RetryError {
operation, err = config.clientContainerBeta.
Expand All @@ -287,8 +292,6 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e
}
timeout -= time.Since(startTime)

d.SetId(fmt.Sprintf("projects/%s/locations/%s/clusters/%s/nodePools/%s", nodePoolInfo.project, nodePoolInfo.location, nodePoolInfo.cluster, nodePool.Name))

waitErr := containerOperationWait(config,
operation, nodePoolInfo.project,
nodePoolInfo.location, "creating GKE NodePool", timeout)
Expand Down

0 comments on commit 95418fd

Please sign in to comment.