@@ -27,23 +27,43 @@ healthCheck() {
2727 HEALTH_CHECK_URL=$1
2828 STATUS=" "
2929 TIMES=${TIMES:- 120}
30+
31+ # Debug: Parse URL and check host resolution
32+ echo " [HC-DEBUG] Checking URL: $HEALTH_CHECK_URL "
33+ host_part=${HEALTH_CHECK_URL#*:// }
34+ host_part=${host_part%% [:/]* }
35+ echo " [HC-DEBUG] Host part: $host_part "
36+ echo " [HC-DEBUG] Host resolution:"
37+ getent hosts " $host_part " || echo " [HC-DEBUG] Host resolution failed for: $host_part "
38+
3039 i=1
3140 while [[ $i -lt ${TIMES} ]];
3241 do
42+ echo " [HC-DEBUG] Attempt $i /$TIMES : Testing $HEALTH_CHECK_URL "
43+
44+ # Debug: Show curl timing and response details
45+ echo " [HC-DEBUG] Curl timing test:"
46+ curl_timing=$( curl -s -o /dev/null -w " HTTP_CODE:%{http_code} CONNECT:%{time_connect}s STARTTRANSFER:%{time_starttransfer}s TOTAL:%{time_total}s" --max-time 3 " $HEALTH_CHECK_URL " 2>&1 || echo " curl_failed" )
47+ echo " [HC-DEBUG] $curl_timing "
48+
49+ # Original health check logic
3350 STATUS=$( curl --max-time 3 -is ${HEALTH_CHECK_URL} | grep -oE " HTTP/.*\s+200" )
3451 if [[ -n " $STATUS " ]]; then
35- echo " ${HEALTH_CHECK_URL} : ${STATUS} "
52+ echo " [HC-DEBUG] SUCCESS: ${HEALTH_CHECK_URL} : ${STATUS} "
3653 return 0
3754 fi
55+
56+ echo " [HC-DEBUG] Attempt $i failed, sleeping 3s..."
3857 sleep 3
3958 i=$(( $i + 1 ))
4059 done
4160
42- echo " Health check failed after $TIMES attempts for ${HEALTH_CHECK_URL} ." >&2
43- echo " Resolver/hosts debug:" >&2
61+ echo " [HC-DEBUG] Health check failed after $TIMES attempts for ${HEALTH_CHECK_URL} ." >&2
62+ echo " [HC-DEBUG] Resolver/hosts debug:" >&2
4463 cat /etc/resolv.conf || true >&2
64+ echo " [HC-DEBUG] All hosts entries:" >&2
4565 getent hosts || true >&2
46- echo " Verbose curl output:" >&2
66+ echo " [HC-DEBUG] Verbose curl output:" >&2
4767 curl -v --max-time 5 -is ${HEALTH_CHECK_URL} || true >&2
4868 exitOnError " {{.Context.ScenarioName}}-{{.Context.CaseName}} url=${HEALTH_CHECK_URL} , status=${STATUS} health check failed!"
4969}
0 commit comments