Health check: treat 3xx as up (gateway :port now redirects)
The HTTP health poller marked anything >=300 as down. With subdomain routing the gateway's :<port> health path returns 302 (redirect to the dashboard subdomain), so castle-gateway showed "down" despite being healthy. Accept <400: a 2xx or 3xx means the server answered; only 4xx/5xx (or a connection error) is down.
This commit is contained in:
@@ -46,7 +46,9 @@ async def _check_http(client: httpx.AsyncClient, name: str, url: str) -> HealthS
|
||||
try:
|
||||
resp = await client.get(url)
|
||||
latency = int((time.monotonic() - start) * 1000)
|
||||
if resp.status_code < 300:
|
||||
# 2xx/3xx = the server answered (a 3xx redirect still means it's alive —
|
||||
# e.g. the gateway's :<port> now redirects to the dashboard subdomain).
|
||||
if resp.status_code < 400:
|
||||
return HealthStatus(id=name, status="up", latency_ms=latency)
|
||||
return HealthStatus(id=name, status="down", latency_ms=latency)
|
||||
except httpx.HTTPError:
|
||||
|
||||
Reference in New Issue
Block a user