Repository navigation
fix(infra): cdk destroy of the Fargate stack works in one run whatever target group is live - #2071
Merged
Merged
Conversation
…r target group is live CodeDeploy swaps which of the blue and green target groups the live listener rules point at. Neither the API path rules nor the test listener declared a dependency on both groups, so CloudFormation could delete a target group before the rule or listener still using it and fail with "in use by a listener" (#1618). Every API path rule and the test listener now depend on both target groups. Only DependsOn entries are added to the synthesised template; no resource, logical id or property changes. A synth test pins the entries for both live colours, and docs/self-hosting/cdk.md says one run suffices. Resolves #1618 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011kqtSDC7sd5ue3m6LuwdXV Signed-off-by: amarkanday <a.markanday@gmail.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.
Resolves #1618
What and why
cdk destroy experimentation-fargate-<env>failed with DELETE_FAILED on a target group "in use by a listener" whenever the last blue/green deployment left the live rules on the other colour. The API path rules (https_listener.add_target_groups) and the TestListener declared no dependency on both target groups, so CloudFormation could delete a group before the rule or listener using it. Both measured staging teardowns hit this once and passed on a retry.Every API path rule and the TestListener now
node.add_dependencyon both the blue and the green target group (infrastructure/cdk/stacks/fargate_service_stack.py).docs/self-hosting/cdk.md("Tearing an environment down") says one run suffices, and that a stack deployed before this change still has the old order (run the teardown again); its claims file pins the sentence to the new test.Template diff: DependsOn only
The fargate stack was synthesised in-process before and after, for the full and core profiles, each with
api_live_target_groupblue and green (4 templates, 45 resources each, no cdk CLI, no context lookup). The only difference in every one: three addedDependsOn: [BlueTargetGroupF108EB01, GreenTargetGroupEEB2DF3E]lists, on the two API path rules and the TestListener. No Replace, no changed logical id or property.Verification
infrastructure/tests/test_listeners_depend_on_both_target_groups.py(live blue and green): fails on main's code (...ApiPaths10Rule... depends on [], not on both target groups), passes with the change.pytest infrastructure/tests -o addopts="" --import-mode=importlib: 1356 passed.scripts/doc_claims.py check: problems: 0;test_docs_only_gate.py: 47 passed;mkdocs build --strict: ok.fargate_service_stack.pyis outside the lint scope and reports the same three findings on main as with this change.NOT VERIFIED
No real
cdk destroyhas run against this: that waits for the next staging teardown. CloudFormation's delete ordering fromDependsOnis its documented behaviour, not something these tests exercise.🤖 Generated with Claude Code
https://claude.ai/code/session_01NpxPyav9uBxNuiXsDvD8qn