-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Conversation
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. |
}) | ||
|
||
// 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. |
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.
Second sentence no longer accurate, timeout in place.
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 |
Addressed all feedback. |
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. |
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 theazurerm_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.