fix: push can't cancel preview teardown (reliable cleanup)#278
Merged
Conversation
A single workflow-wide concurrency group with cancel-in-progress meant a synchronize event (push) right after removing the test-environment label would cancel the running teardown — and the push run itself skips both jobs (label gone), so nothing re-ran teardown and the stack leaked. Move concurrency to per-job groups: - deploy: preview-deploy-<pr>, cancel-in-progress (back-to-back pushes still supersede each other). - teardown: preview-teardown-<pr>, cancel-in-progress: false (never cancelled; repeated teardowns queue and no-op on the missing workspace). Overlapping terraform is serialized by the existing DynamoDB state lock, so cleanup is reliable regardless of event ordering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Bug
Remove the
test-environmentlabel, then immediately push a commit → the preview stack leaks (never torn down).Why
preview-env.ymlused one workflow-wideconcurrencygroup withcancel-in-progress: true:deployjob is skipped (label already gone) and itsteardownjob doesn't matchsynchronize→ both jobs skip.Fix
Per-job concurrency instead of workflow-wide:
preview-deploy-<pr>,cancel-in-progress: true(back-to-back commits still cancel the older deploy).preview-teardown-<pr>,cancel-in-progress: false(a teardown is never cancelled; repeated teardowns queue and no-op on the already-deleted workspace).Any overlapping terraform is serialized by the existing DynamoDB state lock, so cleanup is correct for every event ordering:
Takes effect on merge to main (pull_request workflows run from the base branch's workflow file).