From c943db379faac17ff33957b3285b7195b0977518 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 6 Mar 2026 11:20:54 +0000 Subject: [PATCH] fix: wait_healthy does not fail fast when a service exits or crashes during the health-check window (#387) --- scripts/harb-evaluator/evaluate.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/harb-evaluator/evaluate.sh b/scripts/harb-evaluator/evaluate.sh index 303c75e..96d3b1e 100755 --- a/scripts/harb-evaluator/evaluate.sh +++ b/scripts/harb-evaluator/evaluate.sh @@ -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