pulumi/tests/integration/aliases/python/alias_after_failed_update
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
..
step1 [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
step2 [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
step3 [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00