Skip to content

fix: remove fallback in count_running_containers causing flaky warm container tests#8651

Merged
bnusunny merged 2 commits intodevelopfrom
fix/warm-containers-count-clean
Feb 13, 2026
Merged

fix: remove fallback in count_running_containers causing flaky warm container tests#8651
bnusunny merged 2 commits intodevelopfrom
fix/warm-containers-count-clean

Conversation

@bnusunny
Copy link
Copy Markdown
Contributor

Problem

TestWarmContainersHandlesSigTerm::test_can_invoke_lambda_function_successfully fails intermittently with AssertionError: 3 != 2.

The count_running_containers() method in warm container integration tests had a fallback path: when the MODE env var filtering found zero matching containers (e.g., due to a transient Docker API error during container.reload()), it fell back to returning the count of all running SAM CLI containers. If stale containers from other tests or parallel runs were present, this inflated the count.

Fix

  • Remove the fallback return len(sam_containers) — now strictly returns only the count of containers matching this test's unique MODE UUID
  • Use exact string matching (==) instead of substring matching (in) on the env var
  • Applied to both test_start_api.py and test_start_lambda.py

Testing

Verified via GitHub Actions workflow on fork — 14/14 warm container tests passed across two consecutive runs.

…ontainer tests

The count_running_containers method fell back to counting ALL SAM CLI
containers when MODE env var filtering found no matches. This caused
AssertionError: 3 != 2 when stale containers from other tests were
present.

Changes:
- Remove fallback that returned len(sam_containers) - now strictly
  returns only containers matching this test's unique MODE UUID
- Use exact string matching instead of substring matching on env var
@bnusunny bnusunny requested a review from a team as a code owner February 13, 2026 03:44
@bnusunny bnusunny added this pull request to the merge queue Feb 13, 2026
Merged via the queue into develop with commit 60329e7 Feb 13, 2026
44 checks passed
@bnusunny bnusunny deleted the fix/warm-containers-count-clean branch February 18, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants