mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 09:22:49 -05:00
* feat(ecs): stop service tasks off the reconciler thread so slow graceful stops don't serialize unrelated services (#6619) The service scheduler ran each task's Docker stop on the single reconciler thread, holding the reconciliation pass lock and the task's monitor. A stop waits out every container's stopTimeout, up to two minutes a container, so one slow task held up every other task and service, and several stopped one after another. The reconciler still marks the task STOPPING and deregisters it at once, then hands the Docker stop to a bounded task stopper: eight daemon threads named ecs-task-stopper-N, created only while there is something to stop. When Docker is done the stop lands the task STOPPED under its monitor, with the same exit codes, finish times, network release, cluster count and event ladder as before, and in the task's own account; a failed stop leaves it STOPPING for a later tick to retry, as it always has. A per-task registry keeps the ticks in between from submitting the same stop again. Grace periods are unchanged. Rollouts count only RUNNING tasks, so a task that stays STOPPING longer starts no extra replacement, and a DAEMON replacement still waits for STOPPED. StopTask keeps its synchronous contract. On a task the scheduler is already stopping it waits, outside the task's monitor, for that stop to land instead of stopping the same containers a second time. A container teardown lets the stopper drain before it claims the remaining handles, and afterReset() replaces the stopper along with the reconciler. Stopper threads now change a cluster's running task count while the reconciler launches tasks, so the count is read and written under the cluster's monitor. With real Docker and three services whose containers ignore SIGTERM (stopTimeout 10 seconds), stopping the three old tasks took one 31 second tick, one task after another, before this change, and 13 seconds with all three stopping side by side after it. * fix(ecs): make StopTask wait for a tick's retry of a background stop that failed A background stop that failed can be retried by a reconcile tick before the waiting StopTask takes the task monitor back. StopTask now rechecks for a running stop in a loop, waiting outside the monitor each time, so it never returns STOPPING while Docker is still stopping the task. The background-stop integration test now reads STOPPED under the task monitor, so it also sees the exit codes and cluster count the stop lands. * test(ecs): use the shared InMemoryStorageFactory in the graceful-stop concurrency test --------- Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>