pulumi/pkg/cmd/pulumi
Will Jones 02f6b99735
Introduce the `state repair` command (#17445)
Before performing any operation, Pulumi will by default check that the
state it is operating on is well-formed -- that all resources referenced
in the state (e.g. as dependencies) actually exist in that state, and
that resources are correctly ordered so that states that depend on
others appear after those that they require. If these well-formedness
checks fail, Pulumi will refuse to continue and report a "snapshot
integrity error".

Such errors are both frustrating and scary. Frustrating because it's
Pulumi's fault and now something has to be done before we can proceed.
Scary because the only options for proceeding are:

* Run another operation with `--disable-integrity-checking`, hoping that
the broken state a. won't affect the operation being run negatively and
b. that when the operation completes, it will have coincidentally
written a well-formed state.
* "State surgery" -- using tools such as `state delete` (likely with
`--disable-integrity-checking`) or `state export`/`state import` to
manually fix issues in the snapshot.

While `--disable-integrity-checking` offers a slightly better UX,
requiring less understanding of the underlying issue in order to fix it,
it is riskier, since it combines the act of repairing the state with
another operation. State surgery, on the other hand, is safer, but
requires a low-level understanding of how Pulumi operates. Moreover, it
can be tedious and error-prone, especially when the state is large.

This commit introduces the `state repair` command, which attempts to
combine the best bits of these two options. `state repair` automates
state surgery that in general we know to be safe -- sorting out-of-order
resources (#17403), and pruning dangling references (#17408). While
automatic repair may not always be possible, `state repair` should be
strictly an improvement: the command will leave valid snapshots
untouched and refuse to write snapshots that can't be repaired with
these operations.

Fixes #17446
2024-10-04 13:56:46 +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 Respect existing stack configuration when initialising secret managers (#17465) 2024-10-03 15:40:39 +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 Use RPC methods for yaml codegen (#17285) 2024-09-17 20:04:57 +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 Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +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 Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +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 Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
import.go Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +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 LoginManager to backend package (#17199) 2024-09-10 09:04:49 +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 Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +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 Have `Host.Provider` accept a `PackageDescriptor` (#17244) 2024-09-12 13:17:30 +00:00
package_add.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +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 Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
plugin_install_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +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 Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +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 Fix Typo in preview.go Description (#17327) 2024-09-20 23:52:54 +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 Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +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 Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +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 Add LoginManager to backend package (#17199) 2024-09-10 09:04:49 +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 Enable Copilot link by default (#17293) 2024-09-20 01:15:16 +00:00
up_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
util.go Introduce the `state repair` command (#17445) 2024-10-04 13:56:46 +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 Respect existing stack configuration when initialising secret managers (#17465) 2024-10-03 15:40:39 +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 Support falling back to snapshot secret managers (#17236) 2024-09-18 08:34:21 +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