pulumi/tests/integration/aliases/python
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
..
adopt_component_child Add aliases/python/adopt_component_child test 2023-06-14 05:19:17 -07:00
adopt_into_component Add requirements.txt to all test projects 2019-08-23 15:02:58 -07:00
alias_after_failed_update [engine] Check for old resources first by URN and then aliases (#13883) 2023-09-06 12:17:02 +00:00
extract_component_child Add aliases/python/extract_component_child test 2023-06-14 05:19:17 -07:00
rename Add requirements.txt to all test projects 2019-08-23 15:02:58 -07:00
rename_component Add requirements.txt to all test projects 2019-08-23 15:02:58 -07:00
rename_component_and_child Add requirements.txt to all test projects 2019-08-23 15:02:58 -07:00
rename_component_child Add aliases/python/rename_component_child test 2023-06-14 05:19:17 -07:00
retype_component Add requirements.txt to all test projects 2019-08-23 15:02:58 -07:00
retype_component_child Add aliases/python/retype_component_child test 2023-06-14 05:19:17 -07:00
retype_parents Fix python alias test (#10008) 2022-06-29 21:24:24 +01:00