fix: normalise GATEWAY_HEALTH_URL to base URL before probing
The probe was appending '/detailed' to whatever URL was provided, so GATEWAY_HEALTH_URL=http://host:8642 would try /8642/detailed and /8642 — neither of which are valid routes. Now strips any trailing /health or /health/detailed from the env var and always probes {base}/health/detailed then {base}/health. Accepts bare base URL, /health, or /health/detailed forms.
This commit is contained in:
parent
45595f4805
commit
6ed682f111
@ -330,13 +330,25 @@ def _probe_gateway_health() -> tuple[bool, dict | None]:
|
|||||||
Uses ``/health/detailed`` first (returns full state), falling back to
|
Uses ``/health/detailed`` first (returns full state), falling back to
|
||||||
the simpler ``/health`` endpoint. Returns ``(is_alive, body_dict)``.
|
the simpler ``/health`` endpoint. Returns ``(is_alive, body_dict)``.
|
||||||
|
|
||||||
|
Accepts any of these as ``GATEWAY_HEALTH_URL``:
|
||||||
|
- ``http://gateway:8642`` (base URL — recommended)
|
||||||
|
- ``http://gateway:8642/health`` (explicit health path)
|
||||||
|
- ``http://gateway:8642/health/detailed`` (explicit detailed path)
|
||||||
|
|
||||||
This is a **blocking** call — run via ``run_in_executor`` from async code.
|
This is a **blocking** call — run via ``run_in_executor`` from async code.
|
||||||
"""
|
"""
|
||||||
if not _GATEWAY_HEALTH_URL:
|
if not _GATEWAY_HEALTH_URL:
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
# Normalise to base URL so we always probe the right paths regardless of
|
||||||
|
# whether the user included /health or /health/detailed in the env var.
|
||||||
base = _GATEWAY_HEALTH_URL.rstrip("/")
|
base = _GATEWAY_HEALTH_URL.rstrip("/")
|
||||||
for path in (f"{base}/detailed", base):
|
if base.endswith("/health/detailed"):
|
||||||
|
base = base[: -len("/health/detailed")]
|
||||||
|
elif base.endswith("/health"):
|
||||||
|
base = base[: -len("/health")]
|
||||||
|
|
||||||
|
for path in (f"{base}/health/detailed", f"{base}/health"):
|
||||||
try:
|
try:
|
||||||
req = urllib.request.Request(path, method="GET")
|
req = urllib.request.Request(path, method="GET")
|
||||||
with urllib.request.urlopen(req, timeout=_GATEWAY_HEALTH_TIMEOUT) as resp:
|
with urllib.request.urlopen(req, timeout=_GATEWAY_HEALTH_TIMEOUT) as resp:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user