Skip to content

fix: wait for CloudFormation stack deletion in pipeline bootstrap tearDown#8744

Merged
bnusunny merged 1 commit intodevelopfrom
fix/pipeline-bootstrap-teardown-waiter
Mar 11, 2026
Merged

fix: wait for CloudFormation stack deletion in pipeline bootstrap tearDown#8744
bnusunny merged 1 commit intodevelopfrom
fix/pipeline-bootstrap-teardown-waiter

Conversation

@bnusunny
Copy link
Copy Markdown
Contributor

@bnusunny bnusunny commented Mar 6, 2026

Problem

The test_interactive_pipeline_user_only_created_once integration test was flaky in CI (run #268).

tearDown calls delete_stack but doesn't wait for the deletion to complete. On reruns (via --reruns) or back-to-back test executions, the stack can still be in DELETE_IN_PROGRESS, causing CreateChangeSet to fail:

Error: Failed to create managed resources: An error occurred (ValidationError) when calling the
CreateChangeSet operation: Stack [...] already exists and cannot be created again with the
changeSet [InitialCreation].

Fix

Add a CloudFormation waiter in tearDown that polls every 10s (up to 180s) for each stack deletion to complete before moving on. Timeouts log a warning without failing teardown.

Testing

  • Existing integration tests cover the affected code path
  • The waiter is a standard boto3 CloudFormation waiter with bounded timeout

@bnusunny bnusunny requested a review from a team as a code owner March 6, 2026 17:15
@github-actions github-actions bot added area/package sam package command area/deploy sam deploy command area/validate sam validate command area/build sam build command labels Mar 6, 2026
…rDown

The test_interactive_pipeline_user_only_created_once integration test
was flaky because tearDown called delete_stack without waiting for
completion. On reruns or subsequent test executions, the stack could
still exist (DELETE_IN_PROGRESS), causing CreateChangeSet to fail with
'Stack already exists and cannot be created again with the changeSet
InitialCreation'.

Add a waiter after delete_stack calls in tearDown that polls every 10s
up to a 180s timeout, ensuring stacks are fully deleted before the next
test begins. Timeouts are logged as warnings without failing teardown.
@bnusunny bnusunny force-pushed the fix/pipeline-bootstrap-teardown-waiter branch from fead39e to b13fdb4 Compare March 6, 2026 17:16
@bnusunny bnusunny requested a review from roger-zhangg March 6, 2026 17:16
@bnusunny bnusunny added this pull request to the merge queue Mar 11, 2026
Merged via the queue into develop with commit 20b8404 Mar 11, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command area/deploy sam deploy command area/package sam package command area/validate sam validate command pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants