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

terraform: ResourceProvider.Stop #9536

Merged
merged 10 commits into from
Oct 25, 2016
Merged

terraform: ResourceProvider.Stop #9536

merged 10 commits into from
Oct 25, 2016

Conversation

mitchellh
Copy link
Contributor

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 in refresh 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:

  • Terraform core updated to use Stop
  • helper/schema.Provider updated with Stop-related functions
  • helper/resource has a new helper function for working with Stop
  • providers/azurerm updated as an example of using Stop to cancel an operation

:shipit:

@jbardin
Copy link
Member

jbardin commented Oct 25, 2016

Normally a Context is used for cancellations, deadlines and timeouts. If we're codifying this in the API, could we upgrade to a more flexible/canonical implementation?

@mitchellh
Copy link
Contributor Author

@jbardin It'll be difficult to pass a Context across the RPC barrier, and I can't think of a use case for deadlines or timeouts from a Terraform core perspective that we can't solve by simply calling Stop on the API. I think what I want here is just a really basic notification that you're being stopped, not any rich additional metadata, deadlines, or timeouts.

Timeouts/deadlines WITHIN a resource I believe can be solved via helper/schema changes and shouldn't be a Terraform core feature.

@mitchellh
Copy link
Contributor Author

Talked out of band: agreed that on the provider side a Go Context makes a lot of sense. I've reworked the helper/schema interface and Azure example to use the context.

@jbardin
Copy link
Member

jbardin commented Oct 25, 2016

LGTM (pending travis)

@mitchellh mitchellh merged commit c3a4cff into master Oct 25, 2016
@mitchellh mitchellh deleted the f-provider-stop branch October 25, 2016 18:58
@mitchellh mitchellh restored the f-provider-stop branch October 25, 2016 19:00
mitchellh added a commit that referenced this pull request Oct 25, 2016
This reverts commit c3a4cff, reversing
changes made to 791a02e.

This change requires plugin recompilation and we should hold off until a
minor release for that.
@mitchellh mitchellh deleted the f-provider-stop branch October 25, 2016 19:10
mathieuherbert pushed a commit to mathieuherbert/terraform that referenced this pull request Oct 30, 2016
…top"

This reverts commit c3a4cff, reversing
changes made to 791a02e.

This change requires plugin recompilation and we should hold off until a
minor release for that.
@ghost
Copy link

ghost commented Apr 21, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants