fix(runtime): watchdog canonical liveness

This commit is contained in:
DCCONSTRUCTIONS
2026-08-26 15:26:17 +03:00
parent 4bcc35c1a0
commit 30227b661f
2 changed files with 15 additions and 4 deletions
+4 -4
View File
@@ -157,7 +157,7 @@ class MissionCoreSelfWatchdog:
journal: MissionCoreWatchdogJournal | None = None,
) -> None:
self.policy = policy or MissionCoreWatchdogPolicy()
self.probe = probe or _mission_core_health_probe(
self.probe = probe or _mission_core_liveness_probe(
self.policy.probe_timeout_seconds
)
self.request_shutdown = request_shutdown or _process_group_signal(signal.SIGTERM)
@@ -232,7 +232,7 @@ def watchdog_enabled(environ: Mapping[str, str] = os.environ) -> bool:
return environ.get(WATCHDOG_ENV) == WATCHDOG_ENABLED_VALUE
def _mission_core_health_probe(timeout_seconds: float) -> Probe:
def _mission_core_liveness_probe(timeout_seconds: float) -> Probe:
def probe() -> bool:
connection = http.client.HTTPConnection(
"127.0.0.1",
@@ -240,7 +240,7 @@ def _mission_core_health_probe(timeout_seconds: float) -> Probe:
timeout=timeout_seconds,
)
try:
connection.request("GET", "/api/health", headers={"Connection": "close"})
connection.request("GET", "/api/liveness", headers={"Connection": "close"})
response = connection.getresponse()
payload = response.read(64 * 1024 + 1)
except (OSError, TimeoutError, http.client.HTTPException):
@@ -256,7 +256,7 @@ def _mission_core_health_probe(timeout_seconds: float) -> Probe:
return bool(
isinstance(document, dict)
and document.get("ok") is True
and document.get("status") == "ok"
and document.get("status") == "alive"
and document.get("service") == MISSION_CORE_SERVICE_ID
)
+11
View File
@@ -528,6 +528,17 @@ async def request_validation_error_handler(
return JSONResponse(status_code=422, content={"detail": INVALID_REQUEST_DETAIL})
@app.get("/api/liveness")
async def liveness() -> dict[str, object]:
"""Prove only that the canonical event loop is responsive."""
return {
"ok": True,
"status": "alive",
"service": "mission-core-control-plane",
}
@app.get("/api/health")
def health() -> dict[str, Any]:
return build_runtime_readiness(