Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cause node pool to be written to statefile even if creation fails. #3476

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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