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: architecture/gateway.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ The gateway boots in `main()` (`crates/openshell-server/src/main.rs`) and procee
99
99
1. Connect to the persistence store (`Store::connect`), which auto-detects SQLite vs Postgres from the URL prefix and runs migrations.
100
100
2. Create `ComputeRuntime` with a `ComputeDriver` implementation selected by `OPENSHELL_DRIVERS`:
101
101
-`kubernetes` wraps `KubernetesComputeDriver` in `ComputeDriverService`, so the gateway uses the `openshell.compute.v1.ComputeDriver` RPC surface even without transport.
102
-
-`vm` spawns the sibling`openshell-driver-vm` binary as a local compute-driver process, connects to it over a Unix domain socket, and keeps the libkrun/rootfs runtime out of the gateway binary.
102
+
-`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.
103
103
3. Build `ServerState` (shared via `Arc<ServerState>` across all handlers).
104
104
4.**Spawn background tasks**:
105
105
-`ComputeRuntime::spawn_watchers` -- consumes the compute-driver watch stream, republishes platform events, and runs a periodic `ListSandboxes` snapshot reconcile so the store-backed public sandbox reads stay aligned with the compute driver.
@@ -128,7 +128,7 @@ All configuration is via CLI flags with environment variable fallbacks. The `--d
128
128
|`--grpc-endpoint`|`OPENSHELL_GRPC_ENDPOINT`| None | gRPC endpoint reachable from within the cluster (for sandbox callbacks) |
129
129
|`--drivers`|`OPENSHELL_DRIVERS`|`kubernetes`| Compute backend to use. Current options are `kubernetes` and `vm`. |
130
130
|`--vm-driver-state-dir`|`OPENSHELL_VM_DRIVER_STATE_DIR`|`target/openshell-vm-driver`| Host directory for VM sandbox rootfs, console logs, and runtime state |
131
-
|`--vm-compute-driver-bin`|`OPENSHELL_VM_COMPUTE_DRIVER_BIN`|sibling `openshell-driver-vm` binary | Local VM compute-driver process spawned by the gateway|
131
+
|`--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.|
132
132
|`--vm-krun-log-level`|`OPENSHELL_VM_KRUN_LOG_LEVEL`|`1`| libkrun log level for VM helper processes |
133
133
|`--vm-driver-vcpus`|`OPENSHELL_VM_DRIVER_VCPUS`|`2`| Default vCPU count for VM sandboxes |
134
134
|`--vm-driver-mem-mib`|`OPENSHELL_VM_DRIVER_MEM_MIB`|`2048`| Default memory allocation for VM sandboxes in MiB |
The gateway discovers`openshell-driver-vm`as a sibling of its own binary. Pass `--vm-compute-driver-bin /path/to/openshell-driver-vm` (or set `OPENSHELL_VM_COMPUTE_DRIVER_BIN`) to override.
93
+
The gateway resolves`openshell-driver-vm`in this order: `--driver-dir`, conventional install locations (`~/.local/libexec/openshell`, `/usr/local/libexec/openshell`, `/usr/local/libexec`), then a sibling of the gateway binary.
94
94
95
95
## Flags
96
96
@@ -99,7 +99,7 @@ The gateway discovers `openshell-driver-vm` as a sibling of its own binary. Pass
99
99
|`--drivers vm`|`OPENSHELL_DRIVERS`|`kubernetes`| Select the VM compute driver. |
100
100
|`--grpc-endpoint URL`|`OPENSHELL_GRPC_ENDPOINT`| — | Required. URL the sandbox guest calls back to. Use a host alias that resolves to the gateway's host from inside the VM (gvproxy answers `host.containers.internal` and `host.openshell.internal` to `192.168.127.1`). |
101
101
|`--vm-driver-state-dir DIR`|`OPENSHELL_VM_DRIVER_STATE_DIR`|`target/openshell-vm-driver`| Per-sandbox rootfs, console logs, and the `compute-driver.sock` UDS. |
102
-
|`--vm-compute-driver-bin PATH`|`OPENSHELL_VM_COMPUTE_DRIVER_BIN`|sibling of gateway binary | Override the driver binary path. |
102
+
|`--driver-dir DIR`|`OPENSHELL_DRIVER_DIR`|unset | Override the directory searched for `openshell-driver-vm`. |
103
103
|`--vm-driver-vcpus N`|`OPENSHELL_VM_DRIVER_VCPUS`|`2`| vCPUs per sandbox. |
104
104
|`--vm-driver-mem-mib N`|`OPENSHELL_VM_DRIVER_MEM_MIB`|`2048`| Memory per sandbox, in MiB. |
let path = ifletSome(path) = vm_config.compute_driver_bin.clone(){
136
-
path
137
-
}else{
138
-
let current_exe = std::env::current_exe()
139
-
.map_err(|e| Error::config(format!("failed to resolve current executable: {e}")))?;
140
-
letSome(parent) = current_exe.parent()else{
141
-
returnErr(Error::config(format!(
142
-
"current executable '{}' has no parent directory",
143
-
current_exe.display()
144
-
)));
145
-
};
146
-
parent.join("openshell-driver-vm")
147
-
};
156
+
letmut searched:Vec<PathBuf> = Vec::new();
157
+
158
+
// 1. Configured driver directory, or the conventional install locations
159
+
// when no explicit override is configured.
160
+
for dir inresolve_driver_search_dirs(vm_config){
161
+
let candidate = dir.join(DRIVER_BIN_NAME);
162
+
if candidate.is_file(){
163
+
returnOk(candidate);
164
+
}
165
+
push_unique_path(&mut searched, candidate);
166
+
}
148
167
149
-
if !path.is_file(){
168
+
// 2. Sibling-of-gateway fallback.
169
+
let current_exe = std::env::current_exe()
170
+
.map_err(|e| Error::config(format!("failed to resolve current executable: {e}")))?;
171
+
letSome(parent) = current_exe.parent()else{
150
172
returnErr(Error::config(format!(
151
-
"vm compute driver binary '{}' does not exist; set --vm-compute-driver-bin or OPENSHELL_VM_COMPUTE_DRIVER_BIN",
152
-
path.display()
173
+
"current executable '{}' has no parent directory",
174
+
current_exe.display()
153
175
)));
176
+
};
177
+
let sibling = parent.join(DRIVER_BIN_NAME);
178
+
if sibling.is_file(){
179
+
returnOk(sibling);
180
+
}
181
+
push_unique_path(&mut searched, sibling);
182
+
183
+
let searched_display = searched
184
+
.iter()
185
+
.map(|p| format!("'{}'", p.display()))
186
+
.collect::<Vec<_>>()
187
+
.join(", ");
188
+
Err(Error::config(format!(
189
+
"vm compute driver binary not found (searched {searched_display}); install it under --driver-dir / OPENSHELL_DRIVER_DIR, a conventional libexec path such as ~/.local/libexec/openshell or /usr/local/libexec{{,/openshell}}, or place it next to the gateway binary"
0 commit comments