feat(node): pair onboard computers with the Core fleet through UI
This commit is contained in:
+25
-1
@@ -112,6 +112,7 @@ from k1link.simulation.projects import SimulationProjectService, SimulationProje
|
||||
from k1link.web.advanced_laboratory_api import build_advanced_laboratory_router
|
||||
from k1link.web.artifact_health_api import build_artifact_health_router
|
||||
from k1link.web.compute_contour_api import build_compute_contour_router
|
||||
from k1link.web.fleet_api import router as fleet_router
|
||||
from k1link.web.device_plugin_composition import load_installed_device_plugins
|
||||
from k1link.web.e30_engineering_api import build_e30_engineering_router
|
||||
from k1link.web.e30_human_review_api import build_e30_human_review_router
|
||||
@@ -897,7 +898,24 @@ async def _recorded_blueprint_resource_reaper() -> None:
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def app_lifespan(_: FastAPI) -> AsyncIterator[None]:
|
||||
async def app_lifespan(application: FastAPI) -> AsyncIterator[None]:
|
||||
import logging
|
||||
import sqlite3
|
||||
|
||||
from k1link.fleet.registry import FleetRegistry
|
||||
|
||||
fleet = None
|
||||
application.state.fleet = None
|
||||
try:
|
||||
fleet = FleetRegistry(session_store.data_dir / "fleet")
|
||||
fleet.start()
|
||||
application.state.fleet = fleet
|
||||
except (OSError, ValueError, sqlite3.Error):
|
||||
# Fail closed for pairing without taking down unrelated operator work.
|
||||
if fleet is not None:
|
||||
fleet.close()
|
||||
fleet = None
|
||||
logging.getLogger(__name__).error("Fleet trust storage unavailable; pairing disabled")
|
||||
reconciler: asyncio.Task[None] | None = None
|
||||
publication_reconciler: asyncio.Task[None] | None = None
|
||||
blueprint_reaper: asyncio.Task[None] | None = None
|
||||
@@ -920,6 +938,9 @@ async def app_lifespan(_: FastAPI) -> AsyncIterator[None]:
|
||||
finally:
|
||||
from k1link.viewer.recorded import recorded_blueprint_sessions
|
||||
|
||||
application.state.fleet = None
|
||||
if fleet is not None:
|
||||
await asyncio.to_thread(fleet.close)
|
||||
if blueprint_reaper is not None:
|
||||
blueprint_reaper.cancel()
|
||||
with suppress(asyncio.CancelledError):
|
||||
@@ -950,6 +971,9 @@ app = FastAPI(
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1_024, compresslevel=5)
|
||||
|
||||
|
||||
app.include_router(fleet_router)
|
||||
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def request_validation_error_handler(
|
||||
_: Request,
|
||||
|
||||
Reference in New Issue
Block a user