-
Notifications
You must be signed in to change notification settings - Fork 50
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
Set resource id before polling operation and re-create failed deployments #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely makes sense, but also wondering how things will behave on the next run (assuming there was a failure), since we wouldn't want Terraform to assume that the resource is ready to be used. Perhaps this is a common pattern though? Or maybe this is a place where a state
field would help us?
@roaks3 Yes exactly! I was thinking about how to make the subsequent run obvious that there was a failure and we came to the same conclusion 😄. I am adding a state check on |
If hashicorp/terraform-plugin-sdk#657 (comment) gets resolved in the future, we should return a warning diag. |
If we add a |
I like this idea. So the users are aware there is an issue...and why (on the next run) TF wants to replace it. Do we know how AWS ec2 instances are treated in a similar situation? 🤔 |
@xargs-P Looks like AWS removes the resource based on the |
ah ok, so they expose the instance state to TF. 👌 |
@xargs-P It doesn't appear to be on the resource schema, (which is currently what we have now) but they do check it on the response so this PR implements a similar behavior. |
Turns out this isn't true. Since |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good!
I tried to test this out locally but unfortunately ran into some issues running my local provider. 😩 Hoping to investigate next week!
🤔 Would we need to mirror a solution closer to AWS's? |
Already approved - but now I can say I've exercised this locally too 😎 |
Set the
ID
of resources that need to poll for an operation before polling the operation. This prevents the case where a resource is created in the DB but the async resource operation fails and Terraform has no state entry so it thinks the resource does not exist (even though it does and is in a failed state), so the user can't runterraform destroy
to clean up the failed resource.This PR also sets the Terraform
ID
of resources in a failed state to""
during read. This allows HCP resources (ie a Consul cluster) to be automatically replaced if they failed to provision in the first place. Without this logic, the user would need to look at the HCP UI to determine their cluster/HVN/peering is in aFAILED
state, and delete/recreate manually using Terraform (or the UI and remove from state manually).Failed provision:
On next
terraform plan
:I really wish we could return a warning diag instead of just logging and return
nil
but 🤷