fix: wait_healthy does not fail fast when a service exits or crashes during the health-check window (#387)

This commit is contained in:
openhands 2026-03-06 11:20:54 +00:00
parent 4daabe335d
commit c943db379f

View file

@ -193,9 +193,16 @@ wait_healthy() {
log "Waiting for $service to be healthy (${timeout}s)..."
local deadline=$((SECONDS + timeout))
while (( SECONDS < deadline )); do
local status
status="$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "missing")"
if [[ "$status" == "healthy" ]]; then
local container_state health_status
container_state="$(docker inspect --format='{{.State.Status}}' "$container" 2>/dev/null || echo "missing")"
if [[ "$container_state" == "exited" || "$container_state" == "dead" ]]; then
local exit_code
exit_code="$(docker inspect --format='{{.State.ExitCode}}' "$container" 2>/dev/null || echo "1")"
docker logs "$container" 2>&1 | tail -20 || true
infra_error "$service exited (code $exit_code) before becoming healthy"
fi
health_status="$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "missing")"
if [[ "$health_status" == "healthy" ]]; then
log " $service healthy"
return 0
fi