pulumi/pkg/resource/deploy
Justin Van Patten 4c0b08d8ae
[engine] Check for old resources first by URN and then aliases (#13883)
This change fixes a regression in the step generator when looking for
old resources. When generating steps for a register resource event, we
previously looked for old resources first by the resource's URN and then
by aliases.

This regressed with #10819:

```diff
-	for _, urnOrAlias := range append([]resource.URN{urn}, goal.Aliases...) {
+	aliases[urn] = struct{}{}
+	for urnOrAlias := range aliases {
```

Previously, aliases were in a slice and we always looked for the URN
first, then aliases.

With #10819, aliases changed to being stored in a map (a set). The URN
was added to the map before iterating over it, but there's no guarantee
it will be looked at first (iteration order for maps is unspecified),
and with the current behavior when there are aliases in the map, the URN
very likely won't come first.

This can lead to duplicate resources in the state (stack corruption)
when the wrong old resource is chosen.

The fix is to move back to always checking for old resources using the
URN first. We also move back to maintaining aliases in a slice for
consistent ordering.

Fixes #13848
2023-09-06 12:17:02 +00:00
..
deploytest ci(lint): Upgrade to latest golangci-lint (#13847) 2023-08-31 18:26:04 +00:00
providers Add missing map lock for Registry.RegisterAlias 2023-07-20 09:16:56 +01:00
builtins.go ci(lint): Upgrade to latest golangci-lint (#13847) 2023-08-31 18:26:04 +00:00
deployment.go Consolidated Target parameters 2023-06-08 08:42:03 -07:00
deployment_executor.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
deployment_executor_test.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
deployment_test.go Remove source_fixed 2022-11-08 15:55:45 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
import.go [engine] Add support for source positions 2023-07-10 14:35:40 -07:00
manifest.go Split Manifest type to it's own file (#8712) 2022-01-10 12:25:24 +00:00
plan.go all: Fix revive issues 2023-03-21 08:55:11 -07:00
snapshot.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
snapshot_test.go all: Fix revive issues 2023-03-21 08:55:11 -07:00
source.go [engine] Add support for source positions 2023-07-10 14:35:40 -07:00
source_error.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
source_eval.go Validate resource option URNs 2023-07-19 11:40:37 +01:00
source_eval_test.go Add ConstructInfo to deploytest 2023-07-25 09:03:48 +01:00
source_null.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
source_query.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
source_query_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
state_builder.go all: Fix revive issues 2023-03-21 08:55:11 -07:00
state_builder_test.go Non-mutating snapshot normalization (#10128) 2022-07-18 14:04:19 -04:00
step.go [engine] Add support for source positions 2023-07-10 14:35:40 -07:00
step_executor.go Mark outputs secret if there is a matching secret input. 2023-06-23 09:24:21 -07:00
step_generator.go [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
step_generator_test.go [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
target.go Add getOrganization to nodejs and python (#10504) 2022-08-31 10:33:29 +01:00