Skip to content

Commit 5759d05

Browse files
committed
test(supervisor): cover application streams on config rejection
Verify rejected application configuration closes existing WebSockets without affecting another sandbox, and accepted recovery cannot revive old streams. Document raw SDK message migration and shared-owner selection before discovery. Signed-off-by: Taylor Mutch <[email protected]>
1 parent e3628be commit 5759d05

4 files changed

Lines changed: 81 additions & 1 deletion

File tree

‎crates/openshell-sdk/README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ gateway-name resolution.
1515
surface doesn't yet cover (providers, policy, logs, settings, SSH,
1616
forwarding).
1717

18+
## Raw configuration message migration
19+
20+
`SandboxConfigSnapshot` and `GetSandboxConfigResponse` now include the repeated
21+
`service_routes` field. This is an additive protobuf wire change; ordinary RPC
22+
callers can continue reading responses. It describes the supervisor's declared
23+
application ingress allowlist, not service discovery. An empty list installs no
24+
application routes.
25+
26+
Code constructing complete raw Rust message literals must add
27+
`service_routes: Vec::new()` or use `..Default::default()` for unspecified fields.
28+
Exhaustive destructuring patterns must include `service_routes` or end with `..`.
29+
The curated SDK API is unchanged.
30+
1831
## Auth and refresh
1932

2033
The curated surface drives OIDC refresh automatically: proactively before a

‎crates/openshell-supervisor/src/app_listener.rs‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,11 @@ mod tests {
14031403
tokio_tungstenite::WebSocketStream<tokio_rustls::client::TlsStream<tokio::net::TcpStream>>;
14041404

14051405
async fn websocket(f: &Fixture, service: &str) -> TestWebSocket {
1406-
let host = format!("default--sandbox-a--{service}.svc.openshell.internal");
1406+
sandbox_websocket(f, "sandbox-a", service).await
1407+
}
1408+
1409+
async fn sandbox_websocket(f: &Fixture, sandbox: &str, service: &str) -> TestWebSocket {
1410+
let host = format!("default--{sandbox}--{service}.svc.openshell.internal");
14071411
let stream = openshell_core::net::connect_tcp_nodelay_best_effort(&[f.address])
14081412
.await
14091413
.unwrap();
@@ -1437,6 +1441,42 @@ mod tests {
14371441
assert!(next.is_none() || next.unwrap().is_err());
14381442
}
14391443

1444+
#[tokio::test]
1445+
async fn rejected_configuration_closes_streams_without_affecting_another_sandbox() {
1446+
let f = fixture();
1447+
let second = f.host.router().instance("sandbox-b").unwrap();
1448+
second.routes.install(&installed(vec![SandboxServiceRoute {
1449+
endpoint_id: "endpoint-b".into(),
1450+
..f.route.clone()
1451+
}]));
1452+
let second_connector = Arc::new(Connector {
1453+
calls: AtomicUsize::new(0),
1454+
});
1455+
let _second_handle = second.start(rpc_test::loopback(second_connector));
1456+
let mut rejected_ws = websocket(&f, "web").await;
1457+
let mut unaffected_ws = sandbox_websocket(&f, "sandbox-b", "web").await;
1458+
echo(&mut rejected_ws, "before rejection").await;
1459+
echo(&mut unaffected_ws, "peer before rejection").await;
1460+
1461+
let mut rejected = installed(vec![f.route.clone()]);
1462+
rejected.configuration_admitted = false;
1463+
rejected.configuration_error = "candidate configuration rejected".into();
1464+
f.routes.install(&rejected);
1465+
// A live push session must not renew rejected configuration.
1466+
f.routes.renew();
1467+
assert!(request(&f, HOST, HOST, "").await.is_empty());
1468+
echo(&mut unaffected_ws, "peer survives rejection").await;
1469+
1470+
// Restore before reading the old stream: even coalesced updates must
1471+
// revoke its original token, while new connections can recover.
1472+
f.routes.install(&installed(vec![f.route.clone()]));
1473+
closed(&mut rejected_ws).await;
1474+
let mut recovered_ws = websocket(&f, "web").await;
1475+
echo(&mut recovered_ws, "after accepted configuration").await;
1476+
echo(&mut unaffected_ws, "peer survives recovery").await;
1477+
assert_eq!(f.connector.calls.load(Ordering::SeqCst), 2);
1478+
}
1479+
14401480
#[tokio::test]
14411481
async fn service_edits_close_only_affected_websockets() {
14421482
let f = fixture();

‎e2e/kubernetes/app-listener/README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ The lower-level runner leaves the Helm release and TLS Secret in place. Use
9999
check an already disabled release. Configuration rejection and the additional
100100
deployment cleanup scenarios remain in the manual checklist below.
101101

102+
The supervisor Rust test
103+
`rejected_configuration_closes_streams_without_affecting_another_sandbox`
104+
automates rejection at the listener configuration boundary with real TLS
105+
WebSockets on a shared listener. It checks stream closure, isolation from another
106+
sandbox, and recovery without reviving old streams. Injecting a rejection through
107+
the deployed gateway remains a manual Kubernetes scenario.
108+
102109
## Manual deployment and additional scenarios
103110

104111
Before deployment, provide an operator-owned `openshell-app-tls` Secret in the
@@ -123,6 +130,11 @@ arbitrary member when more than one is present. Check ownership through
123130
supervisor admission/release logs in this stage; automated owner selection
124131
belongs to the later discovery API.
125132

133+
This manual selection validates the listener independently of the later RFC 0017
134+
discovery and routing integrations. A Service balancing across all shared
135+
supervisors cannot select the owner. After takeover, repeat owner selection and
136+
update the test destination; discovery consumers will automate that step.
137+
126138
From a permitted client Pod, mount only the public app certificate/CA and run:
127139

128140
```shell

‎sdk/typescript/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,21 @@ const status = await client.raw.getSandboxPolicyStatus({
310310

311311
The raw layer returns the generated wire messages verbatim, preserving proto distinctions (an omitted optional versus an explicitly empty map) that the curated types may smooth over. As curated sub-clients land, prefer them; `raw` stays as the always-available floor.
312312

313+
### Raw configuration message migration
314+
315+
`SandboxConfigSnapshot` and `GetSandboxConfigResponse` now include a
316+
`serviceRoutes` array. The protobuf wire change is additive, and ordinary RPC
317+
callers continue to receive decoded messages. This field is the supervisor's
318+
declared application ingress allowlist, not service discovery; an empty array
319+
installs no application routes.
320+
321+
Complete object literals typed as either generated message must add
322+
`serviceRoutes: []`. Alternatively, use `create(SandboxConfigSnapshotSchema, init)`
323+
or `create(GetSandboxConfigResponseSchema, init)` from `@bufbuild/protobuf`, with
324+
the corresponding schema imported from `@nvidia/openshell-sdk/raw`. Schema-based
325+
initialization supplies the empty array when omitted. The curated SDK API is
326+
unchanged.
327+
313328
## Boundaries
314329

315330
The SDK ships primitives, not the CLI's terminal experience. Some things are intentionally out of scope:

0 commit comments

Comments
 (0)