Repository navigation
bug(gateway): Ctrl+C on a foreground gateway fails to clean up its ephemeral (--no-keep) MicroVM sandbox and leaves it in Error #4770
Description
User Story
I use OpenShell (0.1.3 and stock 0.1.5) with the MicroVM driver. During development and testing I run openshell-gateway in the foreground of a terminal and create short-lived --no-keep sandboxes from another terminal.
I directly encountered this sequence when I pressed Ctrl+C in the gateway terminal while such a sandbox was running:
- The gateway reported a failed shutdown cleanup.
- The attached
sandbox createreported that the sandbox command exited with status 255; the CLI process itself exited 1. - After the restart, the sandbox stayed in Error until I deleted it by hand.
This affects anyone who stops a foreground gateway with Ctrl+C while it hosts a sandbox.
Problem Statement
On Ctrl+C the terminal sends SIGINT to the whole foreground process group. That group contains the gateway, the VM compute-driver process it spawned and the VM launcher processes. Both the driver and the VMs react to the signal on their own, so the driver exits before the gateway's shutdown sweep asks it to stop the sandbox.
Here is what happens:
- The sweep's stop call fails, and the gateway logs
stopped=0 failed=1andgateway shutdown cleanup failed. - The CLI's ephemeral cleanup cannot reach the gateway either. It reports command status 255 with
ephemeral cleanup failedand exits 1. - On restart, the sandbox's VM has exited with a process-exit error. That reason is not treated as recoverable, so the sandbox remains in Error.
Impact / Why This Matters
- An ephemeral sandbox, which the user asked OpenShell to remove, survives the gateway stop and needs a manual
openshell sandbox delete. - Scripts see exit status 1 from
sandbox create, while the diagnostic says the sandbox command exited 255; both look like a failure of the workload. - The workaround is to stop a foreground gateway with SIGTERM to its pid instead of Ctrl+C, or to delete leftover sandboxes after every restart.
Acceptance Criteria
- Ctrl+C on a foreground gateway that hosts a running
--no-keepsandbox stops and removes that sandbox. The gateway logs no shutdown-cleanup failure. - The attached
sandbox create --no-keepexits with a clear message and a status that says the gateway stopped, not that the cleanup failed. - After a gateway restart, no sandbox is left in Error because of the shutdown. A kept sandbox is Stopped and can be started again.
- The shutdown that a service manager sends (SIGTERM to the gateway) keeps working as today.
Reproduction Steps
- In terminal 1, run
openshell-gateway --config gateway.tomlwithcompute_driver = "vm"in the foreground. - In terminal 2, run
openshell sandbox create --no-keep -- sleep 600. - In terminal 1, press Ctrl+C.
- Restart the gateway in terminal 1, then run
openshell sandbox listin terminal 2.
Expected:
- the sandbox is gone;
- terminal 2 reports that the gateway stopped.
Actual:
- terminal 1 logs
stopped=0 failed=1andgateway shutdown cleanup failed; - terminal 2 prints
ephemeral cleanup failedand exits 1 (after reporting command status 255); - after the restart, the sandbox is listed in Error.
Suggested UX (if applicable)
None.
Environment
- Stock OpenShell 0.1.5 release binaries, checksum verified.
- macOS 15.8 (Darwin kernel 24.6.0), Apple silicon with Apple Hypervisor.framework/libkrun; Docker Desktop 29.8.2. Linux control: RHEL 9.8, kernel 5.14.0-687.45.1.el9_8.x86_64, KVM, Docker 29.8.1, Podman 5.8.2.
- VM driver on both hosts; the isolated gateway and VM launcher shared one process group. SIGINT was sent to that group to reproduce terminal Ctrl+C. The Docker control used an isolated Docker-driver gateway on macOS.
Logs
2026-10-20T22:25:37.575125Z WARN openshell_server::compute: Failed to stop sandbox during gateway shutdown sandbox_id="<sandbox-id>" sandbox_name="internal-caracal" error=code: 'The service is currently unavailable', message: "No such file or directory (os error 2)", source: tonic::transport::Error(Transport, ConnectError(Os { code: 2, kind: NotFound, message: "No such file or directory" }))
2026-10-20T22:25:37.575288Z INFO openshell_server::compute: Sandbox shutdown stop sweep complete stopped=0 failed=1
Error: × execution error: gateway shutdown cleanup failed: failed to stop 1
│ sandbox(es) during gateway shutdown
Error: × sandbox command exited with status 255, but ephemeral cleanup failed:
│ transport error
internal-caracal 2026-10-20 22:24:53 ErrorThe macOS result above was repeated with the checksum-verified Linux v0.1.5 VM driver at 2026-10-20T22:56:30.939377Z (stopped=0 failed=1); after restart, gratified-dealfish was Error. In the Docker control, the gateway logged stopped=1 failed=0, but the CLI printed the same ephemeral cleanup error and exited 1. Its sandbox was Ready after restart.
Activity