-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
terraform: ResourceProvider.Stop #9536
Conversation
b0e0886
to
7328701
Compare
Normally a |
@jbardin It'll be difficult to pass a Timeouts/deadlines WITHIN a resource I believe can be solved via |
Talked out of band: agreed that on the provider side a Go |
a08138b
to
61bbaf6
Compare
LGTM (pending travis) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This introduces a new
ResourceProvider
API:Stop
.This is called when Terraform is interrupted (Ctrl-C). It is mostly advisory, since the previous Stop logic is identical: Terraform core will wait until all currently executing graph nodes complete and then early exit from the graph walk.
The
Stop
API, however, notifies providers in some way that an interrupt has happened. This can be used by longer-running operations to exit early, thus expediting the "clean exit" scenario of interrupting Terraform. For example, waiting for an RDS instance to become ready can take many minutes. If a user ctrl-Cs, this API can be used to exit the wait loop waiting for the DB to become ready, and simply returning a partial state with the DB ID that will be updated inrefresh
in the future.If a provider doesn't implement
Stop
(just returns nil), everything continues to operate as normal: Terraform just waits until the graph nodes complete and then exit as usual.To reiterate: this is aimed primarily to be a UX improvement, although there have been some long (hours long) remote operations that should implement this (such as Azure storage deletion) to make Terraform actually function in those scenarios.
In this PR:
Stop
helper/schema.Provider
updated with Stop-related functionshelper/resource
has a new helper function for working with Stopproviders/azurerm
updated as an example of using Stop to cancel an operation