Repository navigation
feat(server): keep pool sandbox sessions on their supervisor's gateway - #5052
Conversation
…lica A shared supervisor pool sandbox's session now goes to the gateway replica serving its owning member's stream, instead of the replica the ring picks by sandbox ID. Each pool reconciliation pass publishes the sandbox-to-replica map; sessions fall back to the ring when the parent is unknown, not a live peer, or this replica is shutting down. Signed-off-by: divesh <dgude@nvidia.com>
A pool sandbox session served by a replica other than the one serving its owning member is redirected there on its next heartbeat, reusing the shutdown handoff so the sandbox stays Ready. This re-homes sessions left on the wrong replica by a rolling restart. Signed-off-by: divesh <dgude@nvidia.com>
Removes the per-sandbox parent map and the heartbeat relocation; pool sessions will dial their supervisor's gateway directly instead. Signed-off-by: divesh <dgude@nvidia.com>
…plica HostAccepted now carries the accepting replica's peer endpoint. A shared host's sandbox sessions dial it directly, so each session runs on the replica serving its supervisor. A stopping replica sheds its host streams, and redirected sessions follow the host to its next replica. Closes #5051. Signed-off-by: divesh <dgude@nvidia.com>
…ailover Add the shared-supervisor-tree lane: two gateway replicas on PostgreSQL with a two-member supervisor pool. After start, a gateway crash, a gateway rolling restart, and a supervisor crash, every pool sandbox's session runs on the replica serving its supervisor and exec reaches every sandbox. Signed-off-by: divesh <dgude@nvidia.com>
68a5a70 to
efda3de
Compare
|
🌿 Preview your docs: https://nvidia-preview-pr-5052.docs.buildwithfern.com/openshell |
|
Established sandbox sessions do not follow a host that reconnects elsewhere. Before this PR, session placement followed the hash ring independently of the host. This PR colocates sessions initially, but reads This can happen during normal supervisor-token expiry: the gateway closes the host's assignment stream, and the host reconnects through the Service, potentially landing on another replica. Existing sandbox sessions remain on the previous gateway indefinitely, breaking the promised tree topology. Please watch for home changes while a session is active and reconnect when a different nonempty endpoint arrives. Add coverage that moves only the host stream while keeping sandbox sessions healthy; the new gateway crash/restart tests close both and miss this case. Validation: reviewed the full diff and surrounding lifecycle code; did not run tests locally. |
|
Can we fold this coverage into |
…es gateway A host whose stream ends, for example when its supervisor token expires, can reattach to another replica. Its sandbox sessions now watch for that and reconnect to the host's new replica instead of staying on the old one. Signed-off-by: divesh <dgude@nvidia.com>
…-ha lane Run the shared-supervisor-ha lane with two gateway replicas on PostgreSQL and move the gateway crash, rolling restart, and supervisor crash colocation test into it, replacing the separate shared-supervisor-tree lane. Signed-off-by: divesh <dgude@nvidia.com>
…ream ends A host's stream ends routinely, for example when its supervisor token expires. Redialing the replica that accepted it, before falling back to the Service, keeps the host and its sandbox sessions on that replica instead of moving them all on every reconnect. Signed-off-by: divesh <dgude@nvidia.com>
Good find, this is actually much bigger than I thought. I didn't know the host stream gets closed on every token expiry, so hosts were hopping gateways and leaving their sessions behind. Fixed it two ways: the host now redials the same gateway first, so nothing moves in the normal case, and sessions follow the host if it does end up somewhere else. Tested on k3d with short tokens, hosts stayed put across expiries. |
@drew done. |
EmilienM
left a comment
There was a problem hiding this comment.
Another iteration needed: 2 major, 7 minor (inline, 1 below)
A host move that lands while a sandbox session is connecting is swallowed by mark_unchanged(), so the session can stay off its supervisor's gateway. The reconnect loop's Service fallback is also undone by the home re-pin on the next attempt.
Outside the diff:
- Minor:
docs/kubernetes/high-availability.mdx:194,Established streams do not move between gateway replicasis no longer true for pool sandbox sessions, which now follow their host; the page needs a sentence on the new behavior.
How this was reviewed
- Commit
403902950, round 1 - Deep review, because the change reroutes gateway and supervisor sessions (
crates/openshell-server/src/grpc/supervisor_host.rs,crates/openshell-supervisor-process/src/supervisor_session.rs) and reworks the HA e2e lane - Passes: architecture, performance, security, scalability, rust, kubernetes, then correctness
- Independent skeptics checked each candidate finding (3 for the blocking and major code-lens candidate, traced rather than reproduced; 2 for architecture and scalability candidates; 1 for minor ones); 8 of 9 held up
- Repo rules read from
origin/main: AGENTS.md, CLAUDE.md, CONTRIBUTING.md, docs/CONTRIBUTING.mdx, .github/PULL_REQUEST_TEMPLATE.md - Not covered: nothing skipped
TaylorMutch
left a comment
There was a problem hiding this comment.
Local review found one race in the gateway-home watcher, detailed inline. Validation: 131 openshell-supervisor-process tests, 12 openshell-supervisor-control tests, and 17 shared-host tests passed. A focused reproduction using the new watch-channel helpers confirmed the missed update. The Kubernetes HA lane was not run.
An established session marked its host's current gateway as seen before watching it, so a move that landed while the session was connecting was never followed. Compare the current gateway first, then wait for changes. Signed-off-by: divesh <dgude@nvidia.com>
…replica has no peer endpoint Validate the advertised peer endpoint scheme with the shared supervisor, and document that pool sessions follow their supervisor's gateway. Signed-off-by: divesh <dgude@nvidia.com>
…imit Signed-off-by: divesh <dgude@nvidia.com>
|
Added a short note in the HA docs: sandbox sessions stay on their supervisor's gateway and follow it when it moves. |
|
/ok to test 3e2dfab |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. rust-sdk — No explicit risk acceptance foundopenshell_sdk::raw::proto::supervisor_host::v1::HostAccepted gains a third public field, peer_endpoint, invalidating existing two-field struct literals.
Review details
Advisory review; publication gates are unchanged. |
TaylorMutch
left a comment
There was a problem hiding this comment.
Re-reviewed 3e2dfab locally. The previously reported gateway-home watcher race is fixed: the session compares the current home before waiting for changes, and the new session-setup regression test passes. No further actionable code concerns found.
Local validation: 133 openshell-supervisor-process tests, 12 openshell-supervisor-control tests, and 17 shared-host tests passed. Branch Checks and Helm Lint passed for this exact revision. E2E/GPU E2E gates passed without running the optional suites because their labels were not applied; the Windows workflow completed successfully with its build/test jobs skipped. The Kubernetes HA lane was not run locally.
Summary
Each pool sandbox session dials the gateway replica that serves its supervisor, so a sandbox and its parent supervisor always share a gateway.
Closes #5051
Changes
HostAcceptedcarries the accepting replica's peer endpoint.redirected=true, so the replica serves them locally). They wait up to 5 s for it after a host reconnect.e2e:kubernetes:shared-supervisor-hanow runs two gateway replicas on PostgreSQL and checks colocation through gateway and supervisor failures.Testing
openshell-supervisor-control,openshell-supervisor-process,openshell-supervisor,openshell-server