fix(health): move Docker client+ping off the event loop
Under CPU saturation the sync docker.from_env()/ping() calls could miss their socket timeout, cache _docker_healthy=False, and return 503 for the full 5s TTL window. Both calls now run on a thread so the event loop keeps serving other requests while Docker is being probed.
This commit is contained in:
@@ -102,8 +102,8 @@ async def get_health(user: dict = Depends(require_viewer)) -> Any:
|
||||
import docker
|
||||
|
||||
if _docker_client is None:
|
||||
_docker_client = docker.from_env()
|
||||
_docker_client.ping()
|
||||
_docker_client = await asyncio.to_thread(docker.from_env)
|
||||
await asyncio.to_thread(_docker_client.ping)
|
||||
_docker_healthy = True
|
||||
_docker_detail = ""
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user