Skip to content

fix(ecs): forward awslogs before flipping task to STOPPED#752

Merged
vieiralucas merged 1 commit intomainfrom
fix-ecs-awslogs-race
Apr 25, 2026
Merged

fix(ecs): forward awslogs before flipping task to STOPPED#752
vieiralucas merged 1 commit intomainfrom
fix-ecs-awslogs-race

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 25, 2026

Summary

CI was flaking on ecs_task_awslogs_forwards_to_cloudwatch because the runtime called finalize_stopped (writes last_status=STOPPED to ECS state) before forward_awslogs_if_configured (creates the log group/stream and ingests events into fakecloud-logs).

A client polling DescribeTasks until STOPPED and immediately calling DescribeLogStreams could observe STOPPED before the log group existed, getting ResourceNotFoundException.

Reorder so the awslogs forwarding happens first; the STOPPED transition is now the visible signal that "logs are ready."

Test plan

  • cargo build -p fakecloud-ecs clean
  • cargo clippy -p fakecloud-ecs --all-targets -- -D warnings clean
  • ecs_task_awslogs_forwards_to_cloudwatch E2E passes in CI

Summary by cubic

Forward awslogs to CloudWatch before marking ECS tasks as STOPPED to remove a race with clients that query logs right after STOPPED. STOPPED now reliably means the log group/stream exists and logs are ingested.

  • Bug Fixes
    • Reordered runtime shutdown: call forward_awslogs_if_configured(...) before finalize_stopped(...).
    • Prevents ResourceNotFoundException when clients poll DescribeTasks until STOPPED and immediately call DescribeLogStreams.

Written for commit 34b8a3b. Summary will update on new commits.

The runtime was calling finalize_stopped (which writes last_status=STOPPED
to ECS state) before forward_awslogs_if_configured (which materialises
the log group/stream in fakecloud-logs).

A test that polls DescribeTasks until STOPPED and immediately calls
DescribeLogStreams could observe STOPPED before the log group existed,
flaking ecs_task_awslogs_forwards_to_cloudwatch (and any user code that
follows the same pattern). Reorder so log forwarding happens first.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/fakecloud-ecs/src/runtime.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@vieiralucas vieiralucas merged commit 7564af4 into main Apr 25, 2026
48 of 49 checks passed
@vieiralucas vieiralucas deleted the fix-ecs-awslogs-race branch April 25, 2026 18:36
@vieiralucas vieiralucas mentioned this pull request Apr 25, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant