cloudformation: process every StackInstances.update() target independently - #10184
Open
Sohel2309 wants to merge 1 commit into
Open
cloudformation: process every StackInstances.update() target independently#10184Sohel2309 wants to merge 1 commit into
Sohel2309 wants to merge 1 commit into
Conversation
…ently StackInstances.update() (used by UpdateStackInstances) iterated the requested (account, region) targets and raised StackInstanceNotFound as soon as it hit the first target with no existing instance. This abandoned the rest of the batch, so any target listed after the missing one never got updated even though it had an existing instance and should have been - the outcome depended entirely on request-list ordering, which isn't how AWS documents this operation (each account/Region target is modeled as succeeding or failing independently within a single operation). Update every existing target first, then raise StackInstanceNotFoundException for the operation as a whole if any target was missing, so the exception is still surfaced but no longer at the cost of silently dropping updates to other, valid targets. Fixes getmoto#10173 Regression test added that updates two targets where the first one listed is missing and the second one has an existing instance, and asserts the existing instance is still updated despite the exception. Verified the new test fails with the old code (existing instance's ParameterOverrides stays unset) and passes with the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StackInstances.update()raisedStackInstanceNotFoundas soon as it encountered the first missing account/region target, causing valid targets later in the same request to be skipped.This made the result depend on the ordering of the requested targets.
Root cause
StackInstances.update()iterated through the requested account/region combinations and raisedStackInstanceNotFoundimmediately when a matching stack instance was not found.Because the exception was raised inside the loop, the remaining targets were never processed.
Fix
Update all existing targets first while tracking whether any requested target was missing.
After all targets have been processed, raise
StackInstanceNotFoundif at least one target was missing.This preserves the existing error behavior while ensuring valid targets are not silently skipped.
Regression test
Added a regression test covering the ordering-sensitive case where:
StackInstanceNotFoundException.The test fails against the original implementation and passes with the fix.
Validation
ruff format --check: passed.mypyon the modified production file: passed.Fixes #10173