pulumi/pkg/cmd/pulumi
Joe Duffy 24e72c9b51
Implement plugin download cancellation (#17621)
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>
2024-11-12 18:04:25 +00:00
..
convert_testdata Refactor convert command to add entrypoint for pulumi convert debugging 2022-10-01 15:40:17 -07:00
pcl_convert_testdata Support PCL as a convert input (and output) 2022-11-11 10:45:40 +00:00
testdata policy publish: default to default-org if possible (#14090) 2023-10-05 16:51:06 +00:00
about.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
about_env.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
about_test.go Move about information to language plugins (#10392) 2022-08-15 14:55:04 +01:00
ai.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
ai_web.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
cancel.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
config.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
config_env.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
config_env_add.go improve the usage string for the config env add/rm commands (#17407) 2024-09-30 07:39:04 +00:00
config_env_add_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_init.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
config_env_init_test.go Merge ESC Projects feature branch (#17226) 2024-09-10 23:08:09 +00:00
config_env_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
config_env_ls_test.go Merge ESC Projects feature branch (#17226) 2024-09-10 23:08:09 +00:00
config_env_rm.go improve the usage string for the config env add/rm commands (#17407) 2024-09-30 07:39:04 +00:00
config_env_rm_test.go Fix TestConfigEnvXXX flakes (#16496) 2024-06-27 03:48:41 +00:00
config_env_test.go Merge ESC Projects feature branch (#17226) 2024-09-10 23:08:09 +00:00
config_test.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
console.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
convert-trace.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
convert.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
convert_test.go Use RPC methods for yaml codegen (#17285) 2024-09-17 20:04:57 +00:00
crypto.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
crypto_test.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
deployment_run.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
deployment_settings_config.go Add explanations about features to improve UX (#17307) 2024-09-26 14:40:51 +00:00
deployment_settings_config_test.go Add explanations about features to improve UX (#17307) 2024-09-26 14:40:51 +00:00
deployment_settings_ops.go Add explanations about features to improve UX (#17307) 2024-09-26 14:40:51 +00:00
deployment_settings_utils.go Add explanations about features to improve UX (#17307) 2024-09-26 14:40:51 +00:00
deployment_settings_utils_test.go Do not rely on auto api for cloning repos on ds tests (#17071) 2024-08-27 15:41:31 +00:00
destroy.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
env.go Use esc/workspace.DefaultPulumiWorkspace in env cmd (#17104) 2024-08-29 13:08:04 +00:00
errors.go Persist metadata about snapshot integrity errors (#17291) 2024-11-06 17:35:27 +00:00
flags_test.go Set the --continue-on-error flag with PULUMI_CONTINUE_ON_ERROR environment variable (#16442) 2024-06-25 08:28:37 +00:00
gen_completion.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
gen_markdown.go Adjust the link path used in generated CLI docs (#17536) 2024-10-09 22:42:06 +00:00
import.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
import_test.go Add a missing test for the import system (#15664) 2024-03-13 14:13:36 +00:00
install.go plugin versions code reuse (#17311) 2024-09-24 13:36:45 +00:00
login.go add interactive account selection to pulumi login (#17618) 2024-10-28 17:00:41 +00:00
logout.go Move GetCurrentCloudURL to pkg workspace (#17107) 2024-08-30 11:58:09 +00:00
logs.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
logs_test.go Use `assert.NoError` rather than `assert.Nil` (#14233) 2023-10-13 09:46:07 +00:00
main.go Sync panic error message with similar messages (#17184) 2024-09-06 09:03:47 +00:00
new.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
new_acceptance_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
new_ai.go upgrade to latest version of golangci-lint (#15977) 2024-04-19 06:20:33 +00:00
new_ai_test.go Fix AI prompt repetition on Windows (#15010) 2024-01-03 23:03:11 +00:00
new_test.go Replace pkg/errors.Wrap with fmt.Errorf (#17201) 2024-09-09 11:11:46 +00:00
org.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
org_search.go Update pulumi --help documentation to use bucketv2/BucketV2 (#17692) 2024-11-06 10:29:18 +00:00
org_search_ai.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
org_search_ai_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
org_search_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
package.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
package_add.go Remove `pulumi package add` error for YAML (#17560) 2024-10-15 18:45:06 +00:00
package_extract_mapping.go Make the `--out` argument optional for `pulumi package get-mapping` (#17227) 2024-09-13 10:27:20 +00:00
package_extract_schema.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_gen_sdk.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_pack_sdk.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
package_publish.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin.go Fix GetPluginInfo with shimless project plugins (#17115) 2024-08-30 15:51:15 +00:00
plugin_install.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
plugin_install_test.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
plugin_ls.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_rm.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_run.go Implement plugin download cancellation (#17621) 2024-11-12 18:04:25 +00:00
policy.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
policy_disable.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_enable.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_group_ls.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_ls.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_new.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
policy_new_acceptance_test.go Use context.Background in tests (#14029) 2023-09-25 12:25:26 +00:00
policy_new_test.go Use context.Background in tests (#14029) 2023-09-25 12:25:26 +00:00
policy_publish.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_publish_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_rm.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
policy_validate.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
preview.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
preview_test.go Fix hang in --preview-file (#15203) 2024-01-25 18:03:38 +00:00
pulumi.go Switch back to `os/user` to get the current user (#17125) 2024-08-31 18:54:35 +00:00
pulumi_test.go correct version check when we have a dev version installed (#14954) 2023-12-22 16:40:12 +00:00
query.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
refresh.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
replay_events.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
schema.go [codegen/schema] Add a schema checker (#7865) 2021-08-30 19:29:24 -07:00
schema_check.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
stack.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
stack_change_secrets_provider.go Rename `createSecretsManager` to `createSecretsManagerForExistingStack` (#17371) 2024-09-26 11:54:16 +00:00
stack_change_secrets_provider_test.go Lift context parameter to SerializeDeployment/Resource/Operations/Properties (#15929) 2024-04-15 07:45:46 +00:00
stack_export.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_graph.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_graph_test.go Adds a flag to graph command to insert fragment (#14858) 2024-01-08 22:03:08 +00:00
stack_history.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +00:00
stack_import.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_init.go Clean up stack init command's long doc (#17534) 2024-10-28 16:01:04 +00:00
stack_init_test.go Respect existing stack configuration when initialising secret managers (#17465) 2024-10-03 15:40:39 +00:00
stack_ls.go colorize selected stack when listing (#17606) 2024-10-24 06:38:22 +00:00
stack_ls_test.go [test] fix `TestCreatingProjectWithEmptyConfig` flakiness (#14777) 2023-12-08 23:00:49 +00:00
stack_output.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_output_fuzz_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
stack_output_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_rename.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_rm.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_select.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_tag.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
stack_test.go Show a fully qualified stack name in `pulumi stack --show-name -Q` (#16453) 2024-06-26 09:00:22 +00:00
stack_unselect.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
state.go Introduce the `state repair` command (#17445) 2024-10-04 13:56:46 +00:00
state_delete.go Add a minimal state delete test (#17259) 2024-09-16 14:51:24 +00:00
state_delete_test.go Introduce snapshot metadata (#17430) 2024-09-30 16:45:40 +00:00
state_edit.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
state_edit_encoder.go Lift context parameter to SerializeDeployment/Resource/Operations/Properties (#15929) 2024-04-15 07:45:46 +00:00
state_edit_test.go Fix context in state edit command (#15354) 2024-02-07 09:01:56 +00:00
state_move.go Rename `createSecretsManager` to `createSecretsManagerForExistingStack` (#17371) 2024-09-26 11:54:16 +00:00
state_move_test.go Introduce snapshot metadata (#17430) 2024-09-30 16:45:40 +00:00
state_rename.go Centralize resource state dependency traversal (#17320) 2024-09-23 08:37:34 +00:00
state_rename_test.go Allow anything in resource names (#14107) 2023-11-20 08:59:00 +00:00
state_repair.go Introduce the `state repair` command (#17445) 2024-10-04 13:56:46 +00:00
state_repair_render.go Introduce the `state repair` command (#17445) 2024-10-04 13:56:46 +00:00
state_repair_test.go Introduce the `state repair` command (#17445) 2024-10-04 13:56:46 +00:00
state_unprotect.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
state_upgrade.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
state_upgrade_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
terminal.go crypto/ssh/terminal is deprecated 2023-01-12 09:07:34 -08:00
terminal_test.go Fix negative page size panic (#10475) 2022-08-23 16:45:47 -04:00
up.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
up_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
util.go Move EscEnvironmentMetadata to apitype (#17720) 2024-11-08 14:32:13 +00:00
util_remote.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
util_remote_test.go [cli] Experimental support for remote operations 2022-10-27 16:15:59 -07:00
util_test.go Move EscEnvironmentMetadata to apitype (#17720) 2024-11-08 14:32:13 +00:00
version.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
view-trace.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
watch.go Pass ESC Environments on stack update (#17665) 2024-11-07 18:54:46 +00:00
whoami.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00
whoami_test.go Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +00:00