Skip to content

Commit 57e7b2d

Browse files
committed
fix(sandbox): fail closed across supervisor disconnects
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent f7b4b85 commit 57e7b2d

7 files changed

Lines changed: 1030 additions & 93 deletions

File tree

‎architecture/sandbox.md‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ bidirectional `Mediate` RPC carries multiplexed DNS traffic. General application
2929
UDP is unsupported; UDP DNS remains mediated by the supervisor.
3030
The sandbox probes HTTP/2 connection liveness every five seconds and closes
3131
connections that miss a ten-second acknowledgement deadline. Closing a
32-
connection cancels its stream bridges before releasing the exclusive DNS
33-
mediation lease; an authenticated replacement waits for release instead of
34-
preempting a live supervisor. Idle healthy connections remain usable.
32+
connection freezes the owned workload process tree and cancels its stream
33+
bridges before releasing the exclusive DNS mediation lease. The supervisor has
34+
30 seconds to reconnect, replay attach, and reconfirm the boundary. Confirmation
35+
resumes the workload; expiration terminates it. A credential replacement does
36+
not displace the active connection until the new connection is confirmed. Idle
37+
healthy connections remain usable.
3538
Unauthenticated TLS handshakes have a separate bounded asynchronous pool and
3639
five-second deadline, never consuming authenticated control slots or threads.
3740
The socket broker reserves the TCP control-listener port against workload
@@ -574,11 +577,14 @@ environment variables do not configure the separately isolated supervisor.
574577
- Existing raw byte streams are connection scoped. Dynamic policy changes apply
575578
to new connections or the next parsed HTTP request where the proxy can safely
576579
re-evaluate.
577-
- If the supervisor relay drops, the sandbox can keep running, but connect and
578-
exec operations fail until the supervisor registers again. A replacement
579-
supervisor replays the identical sandbox lifecycle and receives the existing
580-
process handle. The sandbox rejects changed launch inputs and releases the
581-
single main-process attachment when the old supervisor transport closes.
580+
- If the supervisor relay drops, the sandbox stops the canonical agent and exec
581+
process groups, rejects new runtime operations, and closes mediated streams.
582+
A replacement supervisor has 30 seconds to authenticate, replay the identical
583+
attach, and reconfirm the boundary. Successful confirmation resumes the
584+
process tree; otherwise the sandbox sends `SIGTERM`, waits the normal stop
585+
grace period, sends `SIGKILL` to survivors, and makes the session terminal.
586+
Explicit supervisor shutdown uses the same terminal transition and requires
587+
an acknowledgement before treating the boundary as stopped.
582588
- If the canonical main process exits, the supervisor durably reports the
583589
normalized result immediately. A foreground create declares a one-shot main
584590
attachment, so the supervisor accepts it even after a fast process exits,

‎crates/openshell-sandbox-backend/src/boundary_protocol.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ pub enum Request {
472472
Terminate {
473473
process_id: String,
474474
},
475+
/// Permanently end this sandbox session and acknowledge that every owned
476+
/// workload process has been terminated.
477+
TerminateBoundary,
475478
Exec {
476479
spec: ExecSpecWire,
477480
},
@@ -508,6 +511,7 @@ impl Request {
508511
| Self::Exec { .. }
509512
| Self::Signal { .. }
510513
| Self::Terminate { .. }
514+
| Self::TerminateBoundary
511515
| Self::ExecSignal { .. }
512516
| Self::Resize { .. }
513517
)
@@ -577,6 +581,7 @@ impl fmt::Debug for Request {
577581
.debug_struct("Terminate")
578582
.field("process_id", process_id)
579583
.finish(),
584+
Self::TerminateBoundary => formatter.write_str("TerminateBoundary"),
580585
Self::Exec { spec } => formatter.debug_tuple("Exec").field(spec).finish(),
581586
Self::ExecSignal { process_id, signal } => formatter
582587
.debug_struct("ExecSignal")
@@ -635,6 +640,7 @@ pub enum Response {
635640
},
636641
Signaled,
637642
Terminated,
643+
BoundaryTerminated,
638644
ExecStarted {
639645
process_id: String,
640646
pty: bool,

0 commit comments

Comments
 (0)