mirror of https://github.com/pulumi/pulumi.git
24e72c9b51
We use context.Background() when invoking plugin installation logic, and generally do not propagate the context to all the various leaf I/O operations performed in the course of installing plugins. As a result, it is impossible to cancel them. Given that plugins can be 100MBs these days, combined with the fact that we hook SIGINT and SIGTERM to block them in attempt to provide a good user experience, this leads to frustratingly long periods of time where you can't cancel an operation. And, ironically, the time during which we're waiting for these plugins to finish downloading is one of the few strictly safe points where cancelling is fine, since generally no state-modifying operations are in flight. This change plumbs the true enclosing context to all of the places it needs to go in order to make plugin installation cancellation work. Note that I added `*WithContext` variants anytime dealing with a public function for compatibility's sake. I will admit, I wish we could just delete the other ones so that this is always an explicit decision. This change also fixes a bug introduced in [a rather old pull request]( https://github.com/pulumi/pulumi/pull/5317/files), whereby we create diagnostic events to tell the user a ^C has been registered -- but then ignore the return values, never sending them to the engine! I have included a test for cancellation. It is deliberately simple so it can be deterministic (e.g., it doesn't test partial operations). I also have not tested the myriad download sources, because it would make the tests dependent on GitHub, GitLab, and other network sources that would likely cause flakiness. Any/all feedback on how to improve coverage here welcome, but it's better than nothing. This fixes pulumi/pulumi#17594. --------- Co-authored-by: Julien <julien@caffeine.lu> |
||
---|---|---|
.. | ||
display | ||
diy | ||
filestate | ||
httpstate | ||
state | ||
apply.go | ||
apply_test.go | ||
backend.go | ||
backend_test.go | ||
cancellation_scope.go | ||
doc.go | ||
errors.go | ||
inmemoryPersister.go | ||
login_manager.go | ||
mock.go | ||
policypack.go | ||
query.go | ||
snapshot.go | ||
snapshot_test.go | ||
stack.go | ||
updates.go | ||
watch.go |