fix(runtime): fail closed on offline artifact misses
This commit is contained in:
+18
-14
@@ -63,6 +63,10 @@ from k1link.web.plugin_runtime import (
|
||||
)
|
||||
from k1link.web.polygon_api import build_polygon_router, configured_polygon_runs_root
|
||||
from k1link.web.runtime_diagnostics import configure_scanner_diagnostics
|
||||
from k1link.web.runtime_readiness import (
|
||||
BackgroundReconcilerReadiness,
|
||||
build_runtime_readiness,
|
||||
)
|
||||
from k1link.web.session_api import build_session_router
|
||||
from k1link.web.system_telemetry_api import build_system_telemetry_router
|
||||
from k1link.web.viewer_diagnostics_api import build_viewer_diagnostics_router
|
||||
@@ -167,6 +171,7 @@ session_perception_epoch_store = (
|
||||
else None
|
||||
)
|
||||
map_gateway_proxy = MapGatewayProxy(MapGatewayConfiguration.from_environment())
|
||||
recording_reconciler_readiness = BackgroundReconcilerReadiness()
|
||||
|
||||
|
||||
def _prepare_recorded_media_for_launch(
|
||||
@@ -281,10 +286,11 @@ async def _recording_preparation_reconciler() -> None:
|
||||
newly_finalized,
|
||||
)
|
||||
known_finalized = finalized
|
||||
except Exception:
|
||||
recording_reconciler_readiness.record_success()
|
||||
except Exception as exc:
|
||||
# A transient filesystem/catalog failure must not permanently
|
||||
# disable preparation of sessions completed later in the run.
|
||||
pass
|
||||
recording_reconciler_readiness.record_failure(exc)
|
||||
await asyncio.sleep(2.0)
|
||||
|
||||
|
||||
@@ -339,18 +345,16 @@ async def request_validation_error_handler(
|
||||
|
||||
@app.get("/api/health")
|
||||
def health() -> dict[str, Any]:
|
||||
runtime_health = plugin_environment.runtime_health
|
||||
runtimes_ready = all(item["status"] == "ready" for item in runtime_health)
|
||||
return {
|
||||
"ok": runtimes_ready,
|
||||
"status": "ok" if runtimes_ready else "degraded",
|
||||
"service": "mission-core-control-plane",
|
||||
"version": __version__,
|
||||
"plugin_runtimes": {
|
||||
"ready": sum(item["status"] == "ready" for item in runtime_health),
|
||||
"total": len(runtime_health),
|
||||
},
|
||||
}
|
||||
return build_runtime_readiness(
|
||||
version=__version__,
|
||||
plugin_runtime_health=plugin_environment.runtime_health,
|
||||
recording_materializer=session_recording_materializer,
|
||||
artifact_gateway=session_artifact_gateway,
|
||||
map_gateway_configured=map_gateway_proxy.configured,
|
||||
ffmpeg_available=_ffmpeg is not None,
|
||||
ffprobe_available=_ffprobe is not None,
|
||||
reconciler=recording_reconciler_readiness,
|
||||
)
|
||||
|
||||
|
||||
@app.get("/api/v1/device-plugins")
|
||||
|
||||
Reference in New Issue
Block a user