Repository navigation
fix(reaper): region-explicit deploy; an unreadable stack must abort, not reset - #666
Merged
Merged
Conversation
…not reset Follow-up to #650. The fix for #650 disarmed the live production reaper. The Makefile's describe-stacks had no --region, so it resolved against the profile's default region, the stack read as 'not found', the `|| echo '[]'` branch wrote an EMPTY live set, and every parameter fell back to its template default — DryRun among them, whose default is 'true'. The reaper went to dry-run: still running, still reporting, terminating nothing. Precisely the failure #650 exists to prevent, reintroduced by the fix for it. What let it past me was the reporting, not the logic. The merge printed 'deploy changes no parameters (code only)' because its change notes only fired when a live value existed to differ from. With no live values there were no notes, so asserting all 16 defaults looked identical to inheriting all 16. I read that message and believed it. Three changes: - Every aws cloudformation call in the deploy path is region-explicit (REGION?=us-east-1), including sam deploy. - A describe-stacks failure that is NOT a genuinely absent stack now ABORTS. Collapsing every failure into '[]' is what silently reset the stack; a first deploy (stack 'does not exist') is still fine and says so. - An empty live set is now the LOUDEST case: it warns that all 16 values come from template defaults and will RESET an existing stack, and lists each one as a change. Tests for all three. TestDeployReadsTheStackInTheRightRegion reads the Makefile, because the region bug is not visible in the merge logic at all — it is in the call that feeds it. Both confirmed to fail when inverted. Production was restored from a snapshot taken before the bad deploy: all 16 parameters match the original with zero drift, DryRun=false, DnsSweep=true, and all five alarms re-wired.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Follow-up to #650. The fix for #650 disarmed the live production reaper. I caught it by checking the stack after deploying rather than trusting the deploy's own output — and the deploy's own output is the reason it got that far.
What happened
The Makefile's
describe-stackscall had no--region. So it resolved against the profile's default region, the stack read as "not found", the|| echo '[]'branch wrote an empty live set, and every parameter fell back to its template default —DryRunamong them, whose default istrue.Result:
DryRun=true, DNS sweep off, DNS domain blanked, alarm topic detached. The reaper kept running and reporting and stopped terminating anything. Precisely the failure #650 exists to prevent, reintroduced by the fix for it.What let it past me
Not the logic — the reporting. The merge printed:
...while setting all 16 from defaults. Its change notes only fired when a live value existed to differ from; with no live values there were no notes, so asserting 16 defaults looked identical to inheriting 16. I read that line and believed it.
That's the more important bug of the two.
Three changes
aws cloudformationcall in the deploy path is region-explicit (REGION?=us-east-1), includingsam deploy.describe-stacksfailure that is not a genuinely absent stack now aborts. Collapsing every failure into'[]'is what silently reset the stack. A first deploy (does not exist) is still fine and says so.Tests
All three, including
TestDeployReadsTheStackInTheRightRegion, which reads the Makefile — the region bug isn't visible in the merge logic at all, it's in the call that feeds it. Both confirmed to fail when inverted.Production state
Restored from a snapshot taken before the bad deploy: all 16 parameters match the original, zero drift,
DryRun=false(armed),DnsSweep=true, and all five alarms re-wired. Verified after restoring, not assumed.Worth saying
This is the second time today a reaper IAM/deploy change looked correct and wasn't — the other being #652's
ec2:ResourceTagon anssm:action (#665). Both share a shape: YAML that no compiler and no test could reach, verified only by asking AWS afterwards. It's a concrete argument for the standing preference to drop CloudFormation and express this in Go against the API, wherepkg/reaperiamalready has a real drift test andpkg/reaperdeployalready makes direct calls.