Fix the Health Check That Kills Workers While They Warm Up
Agent workers load a twelve-second cache when they start. The health check restarts any worker that is not serving, so a worker that is loading gets restarted at tick 10, starts loading again, and the cluster never comes up. Meanwhile a worker whose model call has hung is still being sent traffic. Fix alive, ready, patrol and route.
A Worker records last_progress (the last tick it loaded, took or finished anything), cache_loaded, inflight, draining and restarts. LIVENESS_TIMEOUT and CAPACITY are provided.
alive(worker, now)is False only whennow - worker.last_progress > LIVENESS_TIMEOUT. Loading the cache is progress. A worker is dead when it stops moving, not when it is not ready.ready(worker, now)is True when the worker is alive, its cache is loaded, it is not draining, andinflight < CAPACITY.patrol(workers, now)restarts every worker that is not alive, withworker.restart(now), and returns their indices. It never restarts a worker for being unready.route(workers, now)returns the index of the ready worker with the fewest in-flight tasks, the lowest index on a tie, orNonewhen nobody is ready.
Kubernetes calls these two checks the liveness probe and the readiness probe, and the bug here is the one everybody ships once: a single check wired to both.