Skip to content

Commit 4dce400

Browse files
committed
feat(supervisor): prototype gateway-scoped HA supervisor pool
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 61d4210 commit 4dce400

74 files changed

Lines changed: 12129 additions & 1932 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@ rotate. It also keeps a long-running sandbox alive and runs upload/download
285285
operations while gateway pods roll, so file sync exercises the same relay retry
286286
path as interactive sessions.
287287

288+
Use `mise run e2e:kubernetes:supervisor-topology` for the gateway supervisor
289+
topology prototype (`[openshell.gateway] supervisor_topology = "gateway"`). It
290+
uses `ci/values-supervisor-gateway-topology.yaml` (two gateway replicas, the
291+
external PostgreSQL fixture, Envoy) and runs CLI conformance plus
292+
`kubernetes_supervisor_topology`, which kills and pauses shared supervisor Pods
293+
to check fenced takeover of running agents. The partition step pauses one
294+
supervisor process through `crictl` inside the k3d or kind node container
295+
(`OPENSHELL_E2E_KUBE_NODE_CONTAINER` overrides the derived name); run it only
296+
against a disposable cluster.
297+
288298
If you reuse an existing Skaffold cluster for the full kube suite, make sure the
289299
chart has `server.hostGatewayIP` set so sandbox pods can resolve
290300
`host.openshell.internal` back to the test host. The e2e wrapper detects this on

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/openshell-cli/tests/ensure_providers_integration.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,42 @@ impl TestOpenShell {
7979

8080
#[tonic::async_trait]
8181
impl OpenShell for TestOpenShell {
82+
async fn sync_supervisor_pool(
83+
&self,
84+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
85+
) -> Result<Response<openshell_core::proto::SyncSupervisorPoolResponse>, Status> {
86+
Err(Status::unimplemented("not implemented in test"))
87+
}
88+
89+
async fn get_supervisor_assignment(
90+
&self,
91+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
92+
) -> Result<Response<openshell_core::proto::GetSupervisorAssignmentResponse>, Status> {
93+
Err(Status::unimplemented("not implemented in test"))
94+
}
95+
96+
async fn request_supervisor_recovery_grant(
97+
&self,
98+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
99+
) -> Result<Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>, Status>
100+
{
101+
Err(Status::unimplemented("not implemented in test"))
102+
}
103+
104+
async fn activate_supervisor_assignment(
105+
&self,
106+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
107+
) -> Result<Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>, Status> {
108+
Err(Status::unimplemented("not implemented in test"))
109+
}
110+
111+
async fn renew_supervisor_lease(
112+
&self,
113+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
114+
) -> Result<Response<openshell_core::proto::RenewSupervisorLeaseResponse>, Status> {
115+
Err(Status::unimplemented("not implemented in test"))
116+
}
117+
82118
async fn peer_report_provider_readiness(
83119
&self,
84120
_request: tonic::Request<openshell_core::proto::ReportProviderReadinessRequest>,

‎crates/openshell-cli/tests/mtls_integration.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@ struct TestOpenShell;
3232

3333
#[tonic::async_trait]
3434
impl OpenShell for TestOpenShell {
35+
async fn sync_supervisor_pool(
36+
&self,
37+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
38+
) -> Result<Response<openshell_core::proto::SyncSupervisorPoolResponse>, Status> {
39+
Err(Status::unimplemented("not implemented in test"))
40+
}
41+
42+
async fn get_supervisor_assignment(
43+
&self,
44+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
45+
) -> Result<Response<openshell_core::proto::GetSupervisorAssignmentResponse>, Status> {
46+
Err(Status::unimplemented("not implemented in test"))
47+
}
48+
49+
async fn request_supervisor_recovery_grant(
50+
&self,
51+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
52+
) -> Result<Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>, Status>
53+
{
54+
Err(Status::unimplemented("not implemented in test"))
55+
}
56+
57+
async fn activate_supervisor_assignment(
58+
&self,
59+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
60+
) -> Result<Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>, Status> {
61+
Err(Status::unimplemented("not implemented in test"))
62+
}
63+
64+
async fn renew_supervisor_lease(
65+
&self,
66+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
67+
) -> Result<Response<openshell_core::proto::RenewSupervisorLeaseResponse>, Status> {
68+
Err(Status::unimplemented("not implemented in test"))
69+
}
70+
3571
async fn peer_report_provider_readiness(
3672
&self,
3773
_request: tonic::Request<openshell_core::proto::ReportProviderReadinessRequest>,

‎crates/openshell-cli/tests/provider_commands_integration.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,42 @@ impl TestOpenShell {
232232

233233
#[tonic::async_trait]
234234
impl OpenShell for TestOpenShell {
235+
async fn sync_supervisor_pool(
236+
&self,
237+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
238+
) -> Result<Response<openshell_core::proto::SyncSupervisorPoolResponse>, Status> {
239+
Err(Status::unimplemented("not implemented in test"))
240+
}
241+
242+
async fn get_supervisor_assignment(
243+
&self,
244+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
245+
) -> Result<Response<openshell_core::proto::GetSupervisorAssignmentResponse>, Status> {
246+
Err(Status::unimplemented("not implemented in test"))
247+
}
248+
249+
async fn request_supervisor_recovery_grant(
250+
&self,
251+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
252+
) -> Result<Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>, Status>
253+
{
254+
Err(Status::unimplemented("not implemented in test"))
255+
}
256+
257+
async fn activate_supervisor_assignment(
258+
&self,
259+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
260+
) -> Result<Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>, Status> {
261+
Err(Status::unimplemented("not implemented in test"))
262+
}
263+
264+
async fn renew_supervisor_lease(
265+
&self,
266+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
267+
) -> Result<Response<openshell_core::proto::RenewSupervisorLeaseResponse>, Status> {
268+
Err(Status::unimplemented("not implemented in test"))
269+
}
270+
235271
async fn peer_report_provider_readiness(
236272
&self,
237273
_request: tonic::Request<openshell_core::proto::ReportProviderReadinessRequest>,

‎crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,42 @@ struct TestOpenShell {
101101

102102
#[tonic::async_trait]
103103
impl OpenShell for TestOpenShell {
104+
async fn sync_supervisor_pool(
105+
&self,
106+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
107+
) -> Result<Response<openshell_core::proto::SyncSupervisorPoolResponse>, Status> {
108+
Err(Status::unimplemented("not implemented in test"))
109+
}
110+
111+
async fn get_supervisor_assignment(
112+
&self,
113+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
114+
) -> Result<Response<openshell_core::proto::GetSupervisorAssignmentResponse>, Status> {
115+
Err(Status::unimplemented("not implemented in test"))
116+
}
117+
118+
async fn request_supervisor_recovery_grant(
119+
&self,
120+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
121+
) -> Result<Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>, Status>
122+
{
123+
Err(Status::unimplemented("not implemented in test"))
124+
}
125+
126+
async fn activate_supervisor_assignment(
127+
&self,
128+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
129+
) -> Result<Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>, Status> {
130+
Err(Status::unimplemented("not implemented in test"))
131+
}
132+
133+
async fn renew_supervisor_lease(
134+
&self,
135+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
136+
) -> Result<Response<openshell_core::proto::RenewSupervisorLeaseResponse>, Status> {
137+
Err(Status::unimplemented("not implemented in test"))
138+
}
139+
104140
async fn peer_report_provider_readiness(
105141
&self,
106142
_request: tonic::Request<openshell_core::proto::ReportProviderReadinessRequest>,

‎crates/openshell-cli/tests/sandbox_exec_streaming_integration.rs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,49 @@ macro_rules! mock_gateway {
163163
) => {
164164
#[tonic::async_trait]
165165
impl OpenShell for MockGateway {
166+
async fn sync_supervisor_pool(
167+
&self,
168+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
169+
) -> Result<tonic::Response<openshell_core::proto::SyncSupervisorPoolResponse>, tonic::Status> {
170+
Err(tonic::Status::unimplemented("not implemented in test"))
171+
}
172+
173+
async fn get_supervisor_assignment(
174+
&self,
175+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
176+
) -> Result<tonic::Response<openshell_core::proto::GetSupervisorAssignmentResponse>, tonic::Status>
177+
{
178+
Err(tonic::Status::unimplemented("not implemented in test"))
179+
}
180+
181+
async fn request_supervisor_recovery_grant(
182+
&self,
183+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
184+
) -> Result<
185+
tonic::Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>,
186+
tonic::Status,
187+
> {
188+
Err(tonic::Status::unimplemented("not implemented in test"))
189+
}
190+
191+
async fn activate_supervisor_assignment(
192+
&self,
193+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
194+
) -> Result<
195+
tonic::Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>,
196+
tonic::Status,
197+
> {
198+
Err(tonic::Status::unimplemented("not implemented in test"))
199+
}
200+
201+
async fn renew_supervisor_lease(
202+
&self,
203+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
204+
) -> Result<tonic::Response<openshell_core::proto::RenewSupervisorLeaseResponse>, tonic::Status>
205+
{
206+
Err(tonic::Status::unimplemented("not implemented in test"))
207+
}
208+
166209
$(async fn $method(&self, _: Request<$request>) -> Result<Response<$response>, Status> {
167210
Err(Status::unimplemented("unused test RPC"))
168211
})*

‎crates/openshell-cli/tests/sandbox_name_fallback_integration.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,42 @@ struct TestOpenShell {
4747

4848
#[tonic::async_trait]
4949
impl OpenShell for TestOpenShell {
50+
async fn sync_supervisor_pool(
51+
&self,
52+
_request: tonic::Request<openshell_core::proto::SyncSupervisorPoolRequest>,
53+
) -> Result<Response<openshell_core::proto::SyncSupervisorPoolResponse>, Status> {
54+
Err(Status::unimplemented("not implemented in test"))
55+
}
56+
57+
async fn get_supervisor_assignment(
58+
&self,
59+
_request: tonic::Request<openshell_core::proto::GetSupervisorAssignmentRequest>,
60+
) -> Result<Response<openshell_core::proto::GetSupervisorAssignmentResponse>, Status> {
61+
Err(Status::unimplemented("not implemented in test"))
62+
}
63+
64+
async fn request_supervisor_recovery_grant(
65+
&self,
66+
_request: tonic::Request<openshell_core::proto::RequestSupervisorRecoveryGrantRequest>,
67+
) -> Result<Response<openshell_core::proto::RequestSupervisorRecoveryGrantResponse>, Status>
68+
{
69+
Err(Status::unimplemented("not implemented in test"))
70+
}
71+
72+
async fn activate_supervisor_assignment(
73+
&self,
74+
_request: tonic::Request<openshell_core::proto::ActivateSupervisorAssignmentRequest>,
75+
) -> Result<Response<openshell_core::proto::ActivateSupervisorAssignmentResponse>, Status> {
76+
Err(Status::unimplemented("not implemented in test"))
77+
}
78+
79+
async fn renew_supervisor_lease(
80+
&self,
81+
_request: tonic::Request<openshell_core::proto::RenewSupervisorLeaseRequest>,
82+
) -> Result<Response<openshell_core::proto::RenewSupervisorLeaseResponse>, Status> {
83+
Err(Status::unimplemented("not implemented in test"))
84+
}
85+
5086
async fn peer_report_provider_readiness(
5187
&self,
5288
_request: tonic::Request<openshell_core::proto::ReportProviderReadinessRequest>,

‎crates/openshell-core/src/config.rs‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,44 @@ impl FromStr for PolicyValidationFailureMode {
8383
}
8484
}
8585

86+
/// Where supervisors that enforce sandbox boundaries run.
87+
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
88+
#[serde(rename_all = "snake_case")]
89+
pub enum SupervisorTopology {
90+
/// One supervisor per sandbox, created by the compute driver. Recovery is
91+
/// limited to the same supervisor process.
92+
#[default]
93+
Dedicated,
94+
/// One shared, highly available supervisor Deployment for the whole
95+
/// gateway installation. A failed supervisor is replaced by fenced
96+
/// takeover that resumes the running workload.
97+
Gateway,
98+
}
99+
100+
impl SupervisorTopology {
101+
#[must_use]
102+
pub const fn as_str(self) -> &'static str {
103+
match self {
104+
Self::Dedicated => "dedicated",
105+
Self::Gateway => "gateway",
106+
}
107+
}
108+
}
109+
110+
impl FromStr for SupervisorTopology {
111+
type Err = String;
112+
113+
fn from_str(value: &str) -> Result<Self, Self::Err> {
114+
match value {
115+
"dedicated" => Ok(Self::Dedicated),
116+
"gateway" => Ok(Self::Gateway),
117+
_ => Err(format!(
118+
"invalid supervisor topology '{value}'; expected dedicated or gateway"
119+
)),
120+
}
121+
}
122+
}
123+
86124
/// Default OCI repository for the supervisor image (no tag).
87125
pub const DEFAULT_SUPERVISOR_IMAGE_REPO: &str = "ghcr.io/nvidia/openshell/supervisor";
88126

@@ -209,6 +247,9 @@ pub struct Config {
209247
/// Security posture for rejected sandbox policy generations.
210248
pub policy_validation_failure_mode: PolicyValidationFailureMode,
211249

250+
/// Supervisor placement for sandboxes of this gateway installation.
251+
pub supervisor_topology: SupervisorTopology,
252+
212253
/// TLS configuration. When `None`, the server listens on plaintext HTTP.
213254
pub tls: Option<TlsConfig>,
214255

@@ -883,6 +924,7 @@ impl Config {
883924
metrics_bind_address: None,
884925
log_level: default_log_level(),
885926
policy_validation_failure_mode: PolicyValidationFailureMode::default(),
927+
supervisor_topology: SupervisorTopology::default(),
886928
tls,
887929
oidc: None,
888930
auth: GatewayAuthConfig::default(),

0 commit comments

Comments
 (0)