You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b815cf5
Browse filesBrowse the repository at this point in the historyBrowse files
fix(windows): end sandbox processes when the gateway is killed (#5299)
Own each MXC sandbox generation with a kill-on-close job and place children in that job at process creation. Restrict inherited handles, use non-inheritable gateway sockets, and cover hard-kill and restart behavior with regression tests.
Closes#5298
Signed-off-by: ashwind <ashwind@nvidia.com>
Signed-off-by: Shailendra Singh <shailendras@nvidia.com>
Copy file name to clipboardExpand all lines: crates/openshell-driver-mxc/README.md
+63-3Lines changed: 63 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,7 +222,8 @@ not required; driver-owned guest TLS fields are rejected.
222
222
| Exec, signals, retained output | Authenticated Sandbox Protocol; ConPTY resize is not yet supported |
223
223
| Dynamic forwarding | Standard supervisor `ForwardTcp` path through sandbox loopback connect |
224
224
| ETW/OCSF audit | Optional Windows Sandboxing ETW consumer |
225
-
| Gateway restart recovery | Not yet supported; live MXC generations remain in-memory |
225
+
| Gateway exit | Ends the sandbox processes, workloads included ([details](#gateway-exit-and-restart)) |
226
+
| Gateway restart recovery | Not supported; live MXC generations remain in-memory and are not recovered |
226
227
227
228
Workloads receive the proxy CA in `NODE_EXTRA_CA_CERTS` and `DENO_CERT`, and a
228
229
combined bundle in `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`, `CURL_CA_BUNDLE`, and
@@ -254,6 +255,44 @@ explicit UI policy (including `{}`) for drivers missing this capability; those
254
255
drivers need no UI-specific handling. UI policy itself does not require the
255
256
`allow_driver_config`opt-in. Recreate the sandbox to change these settings.
256
257
258
+
## Gateway exit and restart
259
+
260
+
The driver runs inside the gateway. Each sandbox generation runs in its own
261
+
Windows job object with kill-on-close: the host supervisor and `wxc-exec` are
262
+
created inside it (the job is named in the `CreateProcessW` call, so no process
263
+
of a generation ever exists outside its job, even if the gateway is killed
264
+
mid-spawn), and the boundary and workload processes below them inherit it. When a generation stops, the job is terminated, and when the gateway process
265
+
ends for any reason Windows closes the job and ends everything in it. In
266
+
practice:
267
+
268
+
- **Stop and delete** end the whole generation: supervisor, `wxc-exec`, boundary
269
+
and workload, not only the two direct children.
270
+
- **Graceful gateway stop** (Ctrl-C) ends every sandbox process, workloads
271
+
included, and frees the gateway port.
272
+
- **Gateway crash or hard kill** ends every sandbox process through the job, and
273
+
the listening socket is not inherited by any child, so a new gateway can bind
274
+
the port at once.
275
+
276
+
MXC does not recover sandboxes across a gateway restart. The Docker, Podman and
277
+
VM drivers stop their sandboxes on a graceful gateway stop and recover them when
278
+
the gateway starts again; MXC reports `gateway_manages_lifecycle: false`, so the
279
+
gateway skips that shutdown sweep and startup recovery for it, and live
280
+
generations exist only in the driver's memory. After a restart on the same
281
+
database:
282
+
283
+
- each sandbox record is still listed, with the phase it had when the gateway
284
+
went away (for example `Provisioning` after a graceful stop, `Ready` after a
285
+
hard kill); nothing updates it to show that the workload ended;
286
+
- no workload is running, and nothing restarts it;
287
+
- `openshell sandbox delete <name>`removes the record, and the name can then be
288
+
created again.
289
+
290
+
Treat a sandbox that was running when the gateway exited as lost, delete its
291
+
record, and create it again. The `gateway-kill` and `gateway-restart` E2E
292
+
scenarios (see [Validation](#validation)) check this behavior. Behavior for a
293
+
driver that runs as its own process, separate from the gateway, is not defined
294
+
yet.
295
+
257
296
## Validation
258
297
259
298
Windows build tasks embed the CRT in all four executables and Z3 in the
@@ -351,7 +390,7 @@ explicitly loads the boundary-injected CA bundle and records the peer certificat
351
390
success requires a nonempty response and the OpenShell proxy CA issuer. It does
352
391
not install a host trust root or disable CA/hostname verification. The fixture
353
392
uses best-effort Schannel revocation because the ephemeral private CA has no CRL
354
-
distribution point; it does not qualify revocation enforcement. The default seven E2E
393
+
distribution point; it does not qualify revocation enforcement. The default E2E
355
394
scenarios remain independent of Internet access.
356
395
357
396
The `forwarding` scenario starts a TCP listener inside MXC, then verifies two
@@ -375,12 +414,33 @@ host service is checked before launch and stopped after testing. Select it with
375
414
`-Scenario host-service`; no Internet access, LAN address, or firewall changes
376
415
are required. This verifies direct localhost connectivity.
377
416
417
+
The default `gateway-kill` scenario checks sandbox cleanup when the gateway dies
418
+
without warning. It creates a sandbox with a long-running workload, records the
419
+
sandbox process tree under that gateway, hard-kills the gateway, and requires
420
+
every recorded process to end and the gateway port to be bindable again (a
421
+
replacement gateway must start on it). Only processes under the scenario's own
422
+
gateway are tracked, so other sandboxes on the host are left alone. It relies on
423
+
each sandbox generation's kill-on-close job object; no workload outlives the
424
+
gateway. Select it with `-Scenario gateway-kill`.
425
+
426
+
The default `gateway-restart` scenario covers a graceful gateway stop with
427
+
persisted state. It runs the gateway on a SQLite file, creates a sandbox with a
428
+
long-running workload, sends a real Ctrl-C, and requires the gateway to log a
429
+
graceful shutdown and exit, every recorded sandbox process to end, and a restart
430
+
on the same database to start. After the restart the sandbox record must still be
431
+
listed (the observed phase is `Provisioning` and does not change), its workload
432
+
must not be running (MXC has no restart recovery), and the record must be
433
+
deletable with its name reusable. The scenario pins today's no-recovery behavior,
434
+
so it needs updating when recovery is added. A graceful stop ends the workloads
435
+
with or without the per-generation job; the job is what covers a hard kill.
436
+
Select it with `-Scenario gateway-restart`.
437
+
378
438
The `ws-agent.yaml` and `openclaw-gateway.yaml` policies preserve the Windows
379
439
branch's workload grants. `inference.yaml` is a template: replace its filesystem,
380
440
curl executable, inference host, and port placeholders before use. Authorize
381
441
curl, which owns the network socket, not its cmd launcher. These policies have
382
442
parser/mapper regression coverage; they do not add live WebSocket, OpenClaw,
383
-
or provider-backed inference scenarios to the seven-scenario E2E runner.
443
+
or provider-backed inference scenarios to the E2E runner.
384
444
385
445
With `-KeepRunning`, the runner restores the caller's environment but retains
386
446
the disposable CLI/runtime directory for the live gateway and prints its path.
0 commit comments