Skip to content

Commit 47c3fba

Browse files
authored
Merge pull request #328 from co-cddo/fix/smoke-sweep-orphans-only
fix(smoke): hotfix — orphan-stack sweep skipped live nested children
2 parents 5d87af3 + f03119d commit 47c3fba

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scripts/smoke-pre-deploy-state.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ cleanup_orphan() {
108108
# previous recovery stacks (all-demo-recovery-*).
109109
sweep_orphan_stacks() {
110110
local orphans orphan
111+
# CRITICAL: filter on ParentId being absent. Stacks whose name starts
112+
# with ${STACK}- but ParentId is set are LIVE nested children of the
113+
# active umbrella, not orphans. Without this filter the sweep happily
114+
# deletes the working umbrella's children when called from a healthy
115+
# CREATE_COMPLETE state (which it is — use_canonical runs sweep before
116+
# checking whether the umbrella is alive).
111117
orphans=$(aws cloudformation list-stacks \
112118
--stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE UPDATE_ROLLBACK_COMPLETE DELETE_FAILED UPDATE_ROLLBACK_FAILED CREATE_FAILED UPDATE_FAILED ROLLBACK_COMPLETE ROLLBACK_FAILED \
113-
--query "StackSummaries[?starts_with(StackName, \`${STACK}-\`)].StackName" \
119+
--query "StackSummaries[?starts_with(StackName, '${STACK}-') && ParentId==\`null\`].StackName" \
114120
--output text 2>/dev/null | tr '\t' '\n' | grep -v '^$' || true)
115121
[ -z "$orphans" ] && { echo "No orphan ${STACK}-* stacks to sweep."; return 0; }
116122
echo "Orphan stacks to sweep:"

0 commit comments

Comments
 (0)