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
Copy file name to clipboardExpand all lines: .agents/skills/debug-openshell-cluster/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,7 +184,7 @@ Component images (server, sandbox) can reach kubelet via two paths:
184
184
185
185
**Local/external pull mode** (default local via `mise run cluster`): Local images are tagged to the configured local registry base (default `127.0.0.1:5000/openshell/*`), pushed to that registry, and pulled by k3s via `registries.yaml` mirror endpoint (typically `host.docker.internal:5000`). The `cluster` task pushes prebuilt local tags (`openshell/*:dev`, falling back to `localhost:5000/openshell/*:dev` or `127.0.0.1:5000/openshell/*:dev`).
186
186
187
-
Gateway image builds now stage a partial Rust workspace from `deploy/docker/Dockerfile.images`. If cargo fails with a missing manifest under `/build/crates/...`, or an imported symbol exists locally but is missing in the image build, verify that every current gateway dependency crate (including `openshell-driver-kubernetes` and `openshell-ocsf`) is copied into the staged workspace there.
187
+
Gateway image builds now stage a partial Rust workspace from `deploy/docker/Dockerfile.images`. If cargo fails with a missing manifest under `/build/crates/...`, or an imported symbol exists locally but is missing in the image build, verify that every current gateway dependency crate (including `openshell-driver-docker`, `openshell-driver-kubernetes`, and `openshell-ocsf`) is copied into the staged workspace there.
188
188
189
189
```bash
190
190
# Verify image refs currently used by openshell deployment
| Sandbox index |`crates/openshell-server/src/sandbox_index.rs`|`SandboxIndex` -- in-memory name/pod-to-id correlation |
81
82
| Watch bus |`crates/openshell-server/src/sandbox_watch.rs`|`SandboxWatchBus` -- in-memory broadcast for persisted sandbox updates |
@@ -103,6 +104,7 @@ The gateway boots in `cli::run_cli` (`crates/openshell-server/src/cli.rs`) and p
103
104
1. Connect to the persistence store (`Store::connect`), which auto-detects SQLite vs Postgres from the URL prefix and runs migrations.
104
105
2. Create `ComputeRuntime` with a `ComputeDriver` implementation selected by `OPENSHELL_DRIVERS`:
105
106
-`kubernetes` wraps `KubernetesComputeDriver` in `ComputeDriverService`, so the gateway uses the `openshell.compute.v1.ComputeDriver` RPC surface even without transport.
107
+
-`docker` constructs `openshell-driver-docker` in-process and manages local containers labeled with the configured sandbox namespace.
106
108
-`vm` spawns the standalone `openshell-driver-vm` binary as a local compute-driver process, resolves it from `--driver-dir`, conventional libexec install paths, or a sibling of the gateway binary, connects to it over a Unix domain socket, and keeps the libkrun/rootfs runtime out of the gateway binary.
107
109
3. Build `ServerState` (shared via `Arc<ServerState>` across all handlers), including a fresh `SupervisorSessionRegistry`.
108
110
4.**Spawn background tasks**:
@@ -116,7 +118,7 @@ The gateway boots in `cli::run_cli` (`crates/openshell-server/src/cli.rs`) and p
116
118
117
119
## Configuration
118
120
119
-
All configuration is via CLI flags with environment variable fallbacks. The `--db-url`and `--ssh-handshake-secret`flags are required.
121
+
All configuration is via CLI flags with environment variable fallbacks. The `--db-url`flag is required. The `--ssh-handshake-secret`flag is required for non-Docker drivers; Docker sandboxes do not receive a handshake secret.
120
122
121
123
| Flag | Env Var | Default | Description |
122
124
|------|---------|---------|-------------|
@@ -132,7 +134,7 @@ All configuration is via CLI flags with environment variable fallbacks. The `--d
132
134
|`--sandbox-namespace`|`OPENSHELL_SANDBOX_NAMESPACE`|`default`| Kubernetes namespace for sandbox CRDs |
133
135
|`--sandbox-image`|`OPENSHELL_SANDBOX_IMAGE`| None | Default container image for sandbox pods |
134
136
|`--grpc-endpoint`|`OPENSHELL_GRPC_ENDPOINT`| None | gRPC endpoint reachable from within the cluster (for supervisor callbacks) |
135
-
|`--drivers`|`OPENSHELL_DRIVERS`|`kubernetes`| Compute backend to use. Current options are `kubernetes` and `vm`. |
137
+
|`--drivers`|`OPENSHELL_DRIVERS`|`kubernetes`| Compute backend to use. Current options are `kubernetes`, `docker`, and `vm`. |
136
138
|`--vm-driver-state-dir`|`OPENSHELL_VM_DRIVER_STATE_DIR`|`target/openshell-vm-driver`| Host directory for VM sandbox rootfs, console logs, and runtime state |
137
139
|`--driver-dir`|`OPENSHELL_DRIVER_DIR`| unset | Override directory for `openshell-driver-vm`. When unset, the gateway searches `~/.local/libexec/openshell`, `/usr/local/libexec/openshell`, `/usr/local/libexec`, then a sibling binary. |
138
140
|`--vm-krun-log-level`|`OPENSHELL_VM_KRUN_LOG_LEVEL`|`1`| libkrun log level for VM helper processes |
@@ -600,6 +602,18 @@ The Helm chart template is at `deploy/helm/openshell/templates/statefulset.yaml`
600
602
601
603
The gateway reaches the sandbox exclusively through the supervisor-initiated `ConnectSupervisor` session, so the driver never returns sandbox network endpoints.
602
604
605
+
### Docker Driver
606
+
607
+
The Docker driver (`crates/openshell-driver-docker/src/lib.rs`) is an in-process compute backend for local standalone gateways. It creates one Docker container per sandbox, labels each container with `openshell.ai/managed-by=openshell`, `openshell.ai/sandbox-id`, `openshell.ai/sandbox-name`, and `openshell.ai/sandbox-namespace`, and bind-mounts a Linux `openshell-sandbox` supervisor binary into the container.
608
+
609
+
-**Create**: Pulls or validates the sandbox image according to `sandbox_image_pull_policy`, creates a labeled container, mounts the supervisor binary and optional TLS material, and starts the container with the supervisor as entrypoint.
610
+
-**List/Get/Watch**: Reads labeled containers in the configured sandbox namespace and derives driver-native sandbox status from Docker state plus supervisor relay readiness.
611
+
-**Stop**: Stops the matching labeled container without deleting it.
612
+
-**Delete**: Force-removes the matching labeled container.
613
+
-**Gateway shutdown**: On SIGINT or SIGTERM, `run_server()` leaves the accept loop and calls the Docker shutdown cleanup hook. The hook stops all running, restarting, or paused OpenShell-managed containers in the configured sandbox namespace so local sandboxes do not keep running after the gateway exits.
614
+
-**Gateway startup resume**: Before the watch and reconcile loops spawn, `ComputeRuntime::resume_persisted_sandboxes()` walks every sandbox record in the store. For each sandbox whose phase is `Provisioning`, `Ready`, or `Unknown`, it asks the Docker driver to start the labeled container if it is in the `exited` or `created` state (`StartupResume::resume_sandbox`). Containers in `running` or `restarting` are left alone; `paused`, `dead`, and `removing` are skipped. If the matching container has disappeared, the sandbox is moved to phase `Error` with reason `BackendResourceMissing`; if the start call fails, the sandbox moves to `Error` with reason `ResumeFailed`. This is what makes sandboxes survive a graceful gateway restart end-to-end: shutdown stops them, the next startup resumes them, and the store remains the source of truth across the cycle. Drivers that do not need this hook (Kubernetes, Podman, VM) leave `startup_resume = None`, which makes the resume sweep a no-op.
615
+
-**Handshake secret**: The Docker driver does not inject `OPENSHELL_SSH_HANDSHAKE_SECRET` or `OPENSHELL_SSH_HANDSHAKE_SKEW_SECS` into containers. Supervisor relay auth relies on the gateway connection rather than a Docker-visible container env secret.
616
+
603
617
### VM Driver
604
618
605
619
`VmDriver` (`crates/openshell-driver-vm/src/driver.rs`) is served by the standalone `openshell-driver-vm` process. The gateway spawns that binary on demand and talks to it over the internal `openshell.compute.v1.ComputeDriver` gRPC contract via a Unix domain socket.
Copy file name to clipboardExpand all lines: architecture/sandbox-connect.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -623,7 +623,7 @@ The sandbox SSH daemon's exit thread waits for the reader thread to finish forwa
623
623
624
624
### Sandbox environment variables
625
625
626
-
These are injected into compute-backed sandboxes by the **Kubernetes** driver (`crates/openshell-driver-kubernetes/src/driver.rs`) and the **Podman** driver (`crates/openshell-driver-podman/src/container.rs`). Together they are required for **persistent `ConnectSupervisor` registration and relay** (see [Podman and relay environment](#podman-and-relay-environment) for the Podman-specific fix):
626
+
These are injected into compute-backed sandboxes by the **Kubernetes** driver (`crates/openshell-driver-kubernetes/src/driver.rs`), the **Podman** driver (`crates/openshell-driver-podman/src/container.rs`), and the **Docker** driver (`crates/openshell-driver-docker/src/lib.rs`). Together they are required for **persistent `ConnectSupervisor` registration and relay** (see [Podman and relay environment](#podman-and-relay-environment) for the Podman-specific fix):
0 commit comments