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

helper/signalwrapper and azurerm_storage_account listens for signals #8215

Merged
merged 7 commits into from
Aug 16, 2016

Conversation

mitchellh
Copy link
Contributor

azurerm_storage_account creation can take a long time (24+ hours). If you Ctrl-C, Terraform currently waits for this to complete before cancelling but for this particular resource it is too long.

This PR introduces a new package helper/signalwrapper for easily wrapping functions that can cancel based on signals and early exiting. This package is used with the azurerm_storage_account resource to implement cancellability.

I tested this and it definitely responds to Ctrl-C now. I'm however extremely skeptical in the Azure SDK that it is doing anything other than simply exiting. We don't receive an ID in the cancelled case and it cancels immediately. I'm really scared that we're actually just dangling a resource this way but I haven't gotten the storage account to show up yet. I just can't believe this is actually working, so I'm going to test it more. I'd love your thoughts @stack72 on the Azure stuff. Besides this, 95+% of the LoC in this PR are fine for review and well tested.

So please review but allow me to merge once I verify more behavior.

WARNING: This is not a long term solution. There are very subtle races here: if you Ctrl-C before it reaches the code to create the storage account you could end up waiting anyways. And its also just unclean that provider code is listening for OS signals. In the future, I'd like to introduce a Stop or Cancel API to the ResourceProvider interface that can bubble a stop request through, therefore avoiding the race conditions and also abstracting providers away from "signals" to an API.

@mitchellh
Copy link
Contributor Author

Confirmed a dangling resource. 😵 I'm going to look into this tomorrow but definitely do not merge. Please feel free to review my direction though.

@mitchellh
Copy link
Contributor Author

Fixed the dangling resource reliably and added a 1 hour timeout as well as requested by @phinze and @stack72

})

// Check the result of the wrapped function. I put this into a select
// since we will likely also want to introduce a time-based timeout.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second sentence no longer accurate, timeout in place.

@stack72
Copy link
Contributor

stack72 commented Aug 16, 2016

This LGTM! The use of cancellation channel will be able to be rolled out to all of the AzureRM resources - that was introduced in their SDK 2.1-beta

@mitchellh
Copy link
Contributor Author

Addressed all feedback.

@ghost
Copy link

ghost commented Apr 23, 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 23, 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.

3 participants