fix(health-agent): point Swag Tls external probe at /health instead of unrouted /actuator/health to stop APISIX 404 noise, enable real TLS verification and require HTTP 200; bump version to 0.2.1

This commit is contained in:
Murat ÖZDEMİR 2026-07-16 19:09:34 +03:00
parent 614ade140a
commit a4045711af
2 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[project]
name = "health-agent"
version = "0.2.0"
version = "0.2.1"
description = "iklim.co Monitoring Health Agent"
requires-python = ">=3.12"
dependencies = [

View File

@ -14,7 +14,7 @@ def check_swag_tls():
cert_path = "/mnt/storagebox/ssl/STAR.iklim.co.full.crt"
domain = os.getenv("EXTERNAL_DOMAIN", "iklim.co")
suffix = os.getenv("EXTERNAL_SUBDOMAIN_SUFFIX", "")
target_url = f"https://api{suffix}.{domain}/actuator/health"
target_url = f"https://api{suffix}.{domain}/health"
msg_parts = []
is_down = False
@ -41,17 +41,21 @@ def check_swag_tls():
is_down = True
msg_parts.append(f"cert parse error: {e}")
# 2. Check external HTTPS reachable
# 2. Check external HTTPS reachable with real TLS verification,
# so the served certificate chain is validated, not just the file on disk
try:
r = requests.get(target_url, timeout=5, verify=False)
if r.status_code < 500:
r = requests.get(target_url, timeout=5)
if r.status_code == 200:
msg_parts.append("HTTPS reachable")
else:
is_down = True
msg_parts.append(f"HTTPS returned {r.status_code}")
except Exception as e:
except requests.exceptions.SSLError:
is_down = True
msg_parts.append(f"HTTPS unreachable")
msg_parts.append("TLS verification failed")
except Exception:
is_down = True
msg_parts.append("HTTPS unreachable")
ping_ms = int((time.time() - start_t) * 1000)
msg = " | ".join(msg_parts)