refactor(compute): make sandbox readiness gateway-owned across all drivers#2153
refactor(compute): make sandbox readiness gateway-owned across all drivers#2153elezar wants to merge 2 commits into
Conversation
…ecord helpers Split apply_sandbox_update_locked into named helpers to make the two distinct paths explicit: create_sandbox_record for first-observation events and update_sandbox_record for subsequent driver snapshots on existing sandboxes. The dispatcher now uses a match on the existing record rather than an early-return guard. No behavior change. Signed-off-by: Evan Lezar <elezar@nvidia.com>
|
Label |
|
Label |
| if backend_phase in {Error, Deleting}: → pass through (terminal precedence) | ||
| if backend_phase == Ready && session connected: → Ready | ||
| if backend_phase == Ready && no session: → Provisioning | ||
| if backend_phase in {Provisioning, Unknown} && session: → Ready |
There was a problem hiding this comment.
Is it strange that a non-Ready backend phase can be promoted to Ready if a supervisor session is present?
There was a problem hiding this comment.
Checked the reason: It may be that the supervisor connected event arrives before the backend ready event. In this case, the sandbox is assumed ready because it must be running if the supervisor connected.
84c2c32 to
0767cc7
Compare
…ivers Introduce compute_phase_components and apply_readiness_conditions to centralise the gateway's phase composition logic. The public SandboxPhase is now determined by combining the backend phase reported by the driver with supervisor session presence, independent of the driver implementation. Remove SupervisorReadiness from the driver contract. Running containers always report BackendReady; the gateway owns the Ready decision. Rename the dispatcher match to three arms so that status-less events for existing sandboxes are a documented no-op rather than a silent pass-through. Drop backend_ready_no_session and the SupervisorNotConnected condition. The BackendReady driver condition plus the Provisioning phase already communicates that the backend is up but the supervisor has not connected. The redundant condition added noise without new information. Closes #1951 Signed-off-by: Evan Lezar <elezar@nvidia.com>
0767cc7 to
6ea68c6
Compare
Summary
Centralises the public
SandboxPhase::Readydecision in the gateway. Drivers report backend state only; the gateway composes that with supervisor session presence to produce the public phase. A structural refactor commit extracts the dispatch helpers first so the behavioral change is isolated and readable.Related Issue
Closes #1951
Changes
crates/openshell-server/src/compute/mod.rs: Extractcreate_sandbox_recordandupdate_sandbox_recordhelpers fromapply_sandbox_update_locked; introduceComposedPhaseto encapsulate the four-case composition rule and ownapply_readiness_conditions; add three-arm match dispatcher to make the status-less no-op path explicitcrates/openshell-driver-docker/src/lib.rs: RemoveSupervisorReadinesstrait; running containers always reportBackendReadycrates/openshell-driver-docker/src/tests.rs: Update assertions to reflect droppedSupervisorNotConnectedconditioncrates/openshell-server/src/supervisor_session.rs: Removeimpl SupervisorReadinessblockarchitecture/compute-runtimes.md: Add Sandbox Readiness Composition section documenting the four-case rule, HA note, and extension-point constraint; remove staleSupervisorNotConnectedreferencesDeviations from Plan
None — implemented as planned.
Testing
mise run pre-commitpassesTests updated:
crates/openshell-driver-docker/src/tests.rs— updated three assertions fromSupervisorNotConnectedtoBackendReadyChecklist
Documentation updated:
architecture/compute-runtimes.md: Sandbox Readiness Composition section added