mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
* fix(ecs): reconcile task lifecycle when container exits naturally ECS tasks stayed in RUNNING indefinitely after the underlying Docker container exited, causing `aws ecs wait tasks-stopped` to hang forever and exitCode to remain null. Fixes #889. The 5-second reconciler now also polls running task handles. When all containers for a task have exited, it atomically claims the handle (guarding against a concurrent explicit stopTask), closes log streams, removes the Docker containers, and transitions the task to STOPPED with stoppedAt and per-container exitCode populated. Explicit stopTask is also fixed: it now calls stopTaskAndCollectExitCodes to capture exit codes before the container record is removed, and propagates them to the ECS container model. An idempotency guard prevents double-decrement of runningTasksCount when stopTask is called on a task already transitioned by the reconciler. cleanupStoppedTask is used by the reconciler to avoid re-inspecting containers whose exit codes were already collected in the inspection pass. * fix(ecs): capture exit code after stop, not before stopTaskAndCollectExitCodes inspected containers before stopping them, so getExitCodeIfStopped returned null for still-running containers and the exit code was lost once stopAndRemove deleted the record. Split the operation into two phases: stop all containers first, then inspect exit codes, then remove. Containers already exited skip the stop call silently.