pulumi/pkg/engine
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
..
lifecycletest [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
deployment.go [engine] Add support for source positions 2023-07-10 14:35:40 -07:00
destroy.go Warn about ambient plugins loaded from $PATH 2023-08-08 13:11:34 +01:00
detailedDiff.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
detailedDiff_test.go [display] Refactor diff translation and display. (#9363) 2022-04-07 12:05:33 -07:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
engine.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
errors.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
events.go [apitype] Add RetainOnDelete to StepEventStateMetadata 2023-06-26 12:50:39 -07:00
events_test.go Do not panic when sending events to closed emitter (#10489) 2022-08-25 12:43:10 -04:00
eventsink.go chore: WriteString(Sprintf(..)) => Fprintf(..) 2023-03-01 13:22:33 -08:00
import.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
journal.go Fix engine.Journal to not write out skipped creates 2023-07-21 16:26:40 +01:00
plugin_host.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
plugins.go Warn about ambient plugins loaded from $PATH 2023-08-08 13:11:34 +01:00
plugins_test.go all: Reformat with gofumpt 2023-03-03 09:00:24 -08:00
project.go Update error handling (#8406) 2021-11-12 18:37:17 -08:00
query.go Pass PULUMI_CONFIG through to provider plugins 2023-04-05 10:17:18 +01:00
refresh.go Warn about ambient plugins loaded from $PATH 2023-08-08 13:11:34 +01:00
snapshot.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
update.go Warn about ambient plugins loaded from $PATH 2023-08-08 13:11:34 +01:00
update_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00