Repository navigation
ci(cleanup): pace stack deletes that remove a REST API; retain stuck stacks by time in DELETE_FAILED - #1365
Open
xyos wants to merge 3 commits into
Open
ci(cleanup): pace stack deletes that remove a REST API; retain stuck stacks by time in DELETE_FAILED#1365xyos wants to merge 3 commits into
xyos wants to merge 3 commits into
Conversation
…stacks by time in DELETE_FAILED The scheduled stack sweep triggered delete-stack for every stale stack at once. Each Hosting stack owns a REST API, and API Gateway allows about one DeleteRestApi per 30 seconds per account, so a backlog of 50-100 stacks throttled its own deletes and the PR teardowns running in the same account, and most stacks ended DELETE_FAILED again. - Space deletes of stacks that still own a REST API (nested stacks included) at least 31s apart, like the REST API sweep, and trigger at most 25 per run; the rest wait for the next run. Stacks without a REST API are not paced. A stack whose resources (or a live nested stack's) cannot be listed is deferred too, with a warning that gives the CLI's reason, since whether it owns a REST API is unknown; a nested stack already deleted is not walked. - Skip a stack whose delete is already in progress. - Decide the --retain-resources delete from how long the stack has been DELETE_FAILED (its newest stack-level DELETE_FAILED event, over an hour) instead of its creation time, and issue it as the stack's only delete. It used to follow a plain delete-stack, which CloudFormation rejects with "A delete stack operation is already in progress", so the retain path never ran. - Retain a failed REST API only when its name passes the REST API sweep's name gate, so the sweep reclaims it; others (such as hosting's SsrRestApi) get the plain retry, and a failed name lookup retains nothing. A delete that retains every REST API its stack owns is not paced. - Add scripts/ci/stack-sweep.test.mjs, which runs the step against a stub aws and sleep, run it in PR checks, and check in e2e-stack-prefixes.test.mjs that the retain and sweep name gates match. Cover the Amplify step's nested table retain the same way: a rejected retaining delete gets no plain delete of the same stack in that run.
|
2 of 3 tasks
This branch was previously deployed
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.
Problem
The scheduled stack sweep (
cleanup-stacks.yml, every 2 h, one leg per E2E account) triggersdelete-stackfor every stale stack at once. Each Hosting stack owns a REST API, and API Gateway allows about oneDeleteRestApiper 30 seconds per account. So a backlog of 50–100 stacks throttled its own deletes and the PR teardowns running in the same account, and most stacks endedDELETE_FAILEDagain. Over 2026-11-02/03, account 1'sDELETE_FAILEDbacklog went 3 → 51 → 81 → 109 stacks.The stuck-stack retry that retains blocking resources never ran: in the sweep logs since 2026-11-01 it was attempted 341 times on 147 stacks, and CloudFormation rejected every one with
A delete stack operation is already in progress, because a plaindelete-stackof the same stack always went first.Issue #, if available:
Changes
DELETE_COMPLETEis not walked.DELETE_FAILED(its newest stack-levelDELETE_FAILEDevent, over an hour), not on being created more than 6 h ago. The retaining delete is the stack's only delete call in that run.SsrRestApi, get the plain retry, and a failed name lookup retains nothing.e2e-stack-prefixes.test.mjschecks that the two name gates match.scripts/ci/stack-sweep.test.mjsruns the step's script against stubawsandsleepcommands, and Local Build and Checks runs it.Validation
scripts/ci/stack-sweep.test.mjscovers: pacing and the per-run cap, in-progress skip, the retain basis, retain-as-only-delete (including a rejected retain), the name gate (anSsrRestApiblocker isn't retained; mixed blockers; a failed lookup), failed top-level and nested listings deferring the stack, a deleted nested stack not blocking its parent, and ci(cleanup): unblock Amplify sandboxes stuck on a cancelled table create #970's table retain. Againstmain's step, 13 of its 15 cases fail; the 2 that pass cover behaviour this PR keeps.node --test scripts/ci/*.test.mjs scripts/check-actions-pinned.test.mjs: 504 pass, 0 fail, 12 skipped.actionlintreports nothing oncleanup-stacks.yml.delete-stackcalls spreads the REST API deletes as intended, and how fast a backlog drains. The first scheduled runs after merge will show it in the step summary (triggered / deferred / retained counts).Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.