-
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
command: Make provider installation interruptible #26405
Conversation
We only preserve these major upgrade versions for one major version after they are added, because our upgrade path assumes moving forward only one major version at a time. Now that our main branch is tracking towards Terraform 0.14, we no longer need the 0.13upgrade subcommand. This also includes some minor adjustments to the 0.12upgrade command to align the terminology used in the output of both commands. We usually use the word "deprecated" to mean that something is still available but no longer recommended, but neither of these commands is actually available so "removed" is clearer. We could in principle have removed even the removal notice for 0.12upgrade here, but it's relatively little code and not a big deal to keep around to help prompt those who might try to upgrade directly from 0.11 to 0.14. We may still remove the historical configuration upgrade commands prior to releasing Terraform 1.0, though.
In earlier commits we started to make the installation codepath context-aware so that it could be canceled in the event of a SIGINT, but we didn't complete wiring that through the API of the getproviders package. Here we make the getproviders.Source interface methods, along with some other functions that can make network requests, take a context.Context argument and act appropriately if that context is cancelled. The main providercache.Installer.EnsureProviderVersions method now also has some context-awareness so that it can abort its work early if its context reports any sort of error. That avoids waiting for the process to wind through all of the remaining iterations of the various loops, logging each request failure separately, and instead returns just a single aggregate "canceled" error. We can then set things up in the "terraform init" and "terraform providers mirror" commands so that the context will be cancelled if we get an interrupt signal, allowing provider installation to abort early while still atomically completing any local-side effects that may have started.
Codecov Report
|
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.
I especially like the custom messages you've put in for the 0.12 and 0.13 commands (specifying that one upgrades syntax and the other provider requirements)!
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. |
In earlier commits we started to make the installation codepath context-aware so that it could be canceled in the event of a
SIGINT
, but we didn't complete wiring that through the API of thegetproviders
package.Here we make the
getproviders.Source
interface methods, along with some other functions that can make network requests, take acontext.Context
argument and act appropriately if that context is canceled.The main
providercache.Installer.EnsureProviderVersions
method now also has some context-awareness so that it can abort its work early if its context reports any sort of error. That avoids waiting for the process to wind through all of the remaining iterations of the various loops, logging each request failure separately, and instead returns just a single aggregate "canceled" error.We can then set things up in the
terraform init
andterraform providers mirror
commands so that the context will becancelled if we get an interrupt signal, allowing provider installation to abort early while still atomically completing any local side-effects that may have started.
This fixes #18474, and partially addresses #23647 (because the other operations in
terraform init
are still not interruptible yet.)This PR also bundles in the removal of the
terraform 0.13upgrade
command, which was due to happen before Terraform 0.14 anyway, primarily because it includes calls into thegetproviders
package that I would otherwise have need to update to pass in a context. Reviewing the two commits separately might be easier.