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 bd2a03e
Browse filesBrowse the repository at this point in the historyBrowse files
Document the shared inline and reusable-template resource model, driver behavior, migration from legacy template resource sections, and updated SDK examples.
Part of #2838
Signed-off-by: Evan Lezar <[email protected]>
Copy file name to clipboardExpand all lines: architecture/compute-runtimes.md
+23-12Lines changed: 23 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,20 +271,21 @@ delete, reconciliation removes the row; otherwise it can remain `Deleting`.
271
271
| VM | Experimental microVM isolation. | Per-sandbox libkrun or QEMU VM. | The NIC-less guest runs `openshell-sandbox` as PID 1; host `openshell-supervisor` owns gateway networking and reaches the guest over vsock. |
272
272
| Extension | Out-of-tree drivers operated alongside the gateway. | Whatever boundary the driver implements. | Selected by a custom `compute_drivers = ["<name>"]` entry with `[openshell.drivers.<name>].socket_path`, or at launch time by pairing `--drivers <name>` with `--compute-driver-socket=<path>`. A launch-time endpoint may use a canonical built-in name to preserve its driver-config key while replacing in-process construction. The gateway connects to an operator-provisioned UDS, snapshots `GetCapabilities`, and dispatches all sandbox lifecycle calls through `compute_driver.proto`. The driver process and socket lifecycle are operator-owned; the gateway does not spawn, supervise, or remove unmanaged extension drivers. The trust boundary is the socket's filesystem permissions: the operator must ensure only the gateway uid can read/write it. |
273
273
274
-
Per-sandbox CPU and memory values currently enter the driver layer through
275
-
template resource limits. Docker and Podman apply them as runtime limits.
276
-
Kubernetes mirrors each limit into the matching request. VM accepts the fields
277
-
but currently ignores them.
274
+
Per-sandbox CPU, memory, and GPU requirements enter the driver layer through
275
+
the typed `ResourceRequirements` message. Docker and Podman apply CPU and
276
+
memory as runtime limits. Kubernetes mirrors each limit into the matching
277
+
request. VM and MXC reject unsupported CPU and memory requirements instead of
278
+
silently ignoring them.
278
279
279
280
Reusable sandbox workload templates are resolved before the compute-driver
280
281
boundary. Drivers do not receive a separate template resource; the gateway
281
282
lowers the selected `SandboxWorkloadTemplate` into the existing sandbox spec
282
283
and validates that spec before calling `ValidateSandboxCreate` or
283
-
`CreateSandbox`. Template CPU and memory become the same typed resource limits
284
-
described above. Template GPU settings become `ResourceRequirements`, preserving
285
-
the driver's default GPU assignment when the count is omitted. Template
286
-
`driver_config` remains a driver-keyed envelope until the compute layer selects
287
-
the active driver block and forwards only that block to the driver.
284
+
`CreateSandbox`. `SandboxWorkloadConfig.resources` reuses the public
285
+
`ResourceRequirements` message, so the gateway clones the typed requirements
286
+
directly into the resolved sandbox spec. Template`driver_config` remains a
287
+
driver-keyed envelope until the compute layer selects the active driver block
288
+
and forwards only that block to the driver.
288
289
289
290
Docker and Podman also accept per-sandbox driver-config mounts for existing
290
291
runtime-managed named volumes and tmpfs mounts. Podman additionally accepts
@@ -314,9 +315,19 @@ disjoint lifecycle ownership. A shared-mode gateway can target one external
314
315
namespace, while operator mode maps workspace names to multiple
315
316
platform-provisioned namespaces.
316
317
317
-
Resource requirements enter the driver layer through `SandboxSpec.resource_requirements`. This includes a set of GPU requirements, where a user
318
-
can request a specific number of GPUs or the driver-specific default behaviour.
319
-
For all in-tree drivers, this is equivalent to selecting a single GPU.
318
+
Resource requirements enter the driver layer through `SandboxSpec.resource_requirements`,
319
+
which carries typed GPU, CPU, and memory requirements as portable sandbox-sizing intent.
320
+
GPU requests let a user ask for a specific number of GPUs or the driver-specific default
321
+
behaviour; for all in-tree drivers, an unspecified count is equivalent to selecting a
322
+
single GPU. CPU and memory requirements carry independent optional request and limit
323
+
quantities (e.g. `"500m"`, `"4Gi"`). Docker and Podman apply limits and reject independent
324
+
requests; Kubernetes applies both, falling back from a limit to a request only when no
325
+
typed or driver-config request is set. The VM and MXC drivers reject typed CPU/memory
326
+
requirements with a clear error until sizing support lands there, rather than silently
327
+
ignoring them.
328
+
`SandboxTemplate.resources` remains a platform-native escape hatch for non-portable fields
329
+
only — CPU/memory keys under it are rejected in favor of
Copy file name to clipboardExpand all lines: docs/reference/sandbox-compute-drivers.mdx
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,11 +89,6 @@ The gateway connects to the operator-provided endpoint; it does not provision
89
89
or supervise the remote driver. The operator must protect the socket so only
90
90
the gateway uid can access it.
91
91
92
-
Sandbox create supports `--cpu` and `--memory` for per-sandbox compute sizing.
93
-
Docker and Podman apply them as runtime limits. Kubernetes applies them as both
94
-
container requests and limits. The VM driver accepts the fields but currently
95
-
ignores them.
96
-
97
92
Sandbox create also accepts experimental driver-owned config through
98
93
`--driver-config-json`. The value is a JSON object keyed by driver name. The
99
94
gateway forwards only the block for the active driver, so a Kubernetes gateway
@@ -133,6 +128,36 @@ request. The VM driver accepts `gpu_device_ids`, for example
133
128
accepts at most one entry and allows either `--gpu` or `--gpu 1` when
134
129
`gpu_device_ids` is set.
135
130
131
+
## Portable Resource Requirements
132
+
133
+
CPU, memory, and GPU requests use the typed
134
+
`SandboxSpec.resource_requirements` API:
135
+
136
+
-`cpu.limit` and `memory.limit` are optional portable limits.
137
+
-`cpu.request` and `memory.request` are optional portable requests, supported
138
+
independently by Kubernetes.
139
+
-`gpu` indicates a GPU request and can include an optional count.
140
+
141
+
Reusable workload templates use this same message at
142
+
`SandboxWorkloadConfig.resources`. The gateway copies those typed requirements
143
+
into the resolved sandbox spec when a sandbox is created from a template.
144
+
145
+
| Driver | CPU and memory behavior |
146
+
|---|---|
147
+
| Docker | Converts typed limits to native container CPU and memory limits. |
148
+
| Podman | Converts typed limits to native container CPU and memory limits. |
149
+
| Kubernetes | Applies typed limits and requests independently. A limit becomes the request only when neither a typed request nor a Kubernetes driver-config request is set. |
150
+
| VM | Rejects typed CPU and memory requirements. Configure gateway-wide `vcpus` and `mem_mib` instead. |
151
+
| MXC | Rejects typed CPU and memory requirements. |
152
+
153
+
The historical inline `SandboxTemplate.resources` remains available for platform-native resource
154
+
fields that do not have a portable representation. Do not place CPU or memory
155
+
under its `limits` or `requests` sections. The gateway rejects `limits.cpu`,
156
+
`limits.memory`, `requests.cpu`, and `requests.memory` and directs the caller to
157
+
the corresponding typed field. Kubernetes driver configuration may still set
158
+
requests for Kubernetes-specific workload configuration; typed requests take
159
+
precedence when both are present.
160
+
136
161
## Resource Capability Reporting
137
162
138
163
API clients can read each configured driver's static resource request support
CPU values use Kubernetes-style quantities such as `500m`, `1`, or `2.5`.
87
87
Memory values use byte quantities such as `512Mi`, `4Gi`, or `8G`.
88
88
89
-
Docker and Podman apply these values as runtime limits. Kubernetes applies each
90
-
value as both the request and the limit so the scheduler reserves the same
91
-
amount the sandbox can use. The VM driver currently accepts these flags but
92
-
does not change VM allocation.
89
+
OpenShell stores these values as typed portable resource requirements. Docker
90
+
and Podman apply them as runtime limits. Kubernetes uses each limit as its
91
+
request only when no request was set separately. The VM and MXC drivers reject
92
+
CPU or memory requirements because they do not currently support per-sandbox
93
+
sizing. For VM gateways, configure `vcpus` and `mem_mib` on the driver instead.
94
+
95
+
API and SDK callers can set`cpu.request` and `memory.request` independently
96
+
of their optional limits. Kubernetes honors those typed requests. It also
97
+
accepts requests in its driver configuration for workloads that need
98
+
Kubernetes-specific settings; a typed request takes precedence over the driver
99
+
configuration, and a driver-config request takes precedence over the
100
+
limit-to-request fallback. The `--cpu` and `--memory` flags continue to set
101
+
limits only.
102
+
103
+
<Warning>
104
+
CPU and memory values under `SandboxTemplate.resources.limits` or
105
+
`SandboxTemplate.resources.requests` are no longer supported. API clients must
106
+
use `SandboxSpec.resource_requirements.cpu.request` or `.limit` and
107
+
`SandboxSpec.resource_requirements.memory.request` or `.limit`. The gateway
108
+
rejects legacy requests with a migration error.
109
+
</Warning>
93
110
94
111
### Driver-Specific Configuration
95
112
@@ -256,6 +273,13 @@ Create a sandbox from a template:
256
273
openshell sandbox create --template gpu-kata --provider github -- claude
257
274
```
258
275
276
+
When the gateway creates a sandbox from a template, it resolves the template's
277
+
CPU, memory, and GPU settings into the sandbox's typed `resource_requirements`.
278
+
The reusable template field `SandboxWorkloadConfig.resources` uses the same
279
+
`ResourceRequirements` message as `SandboxSpec.resource_requirements`, so API
280
+
and SDK callers use `cpu.request`/`cpu.limit`, `memory.request`/`memory.limit`,
281
+
and `gpu` in both places.
282
+
259
283
The `--template` flag cannot be combined with inline workload flags such as `--from`, `--cpu`, `--memory`, `--gpu`, `--env`, or `--driver-config-json`. Put those values on the template instead. Create-time policy and provider attachments remain part of the sandbox request, so each sandbox can keep its own access boundary.
-`--gpu [COUNT]`: Request the driver's default GPU selection or a specific GPU count
255
-
-`--cpu`, `--memory`: Set per-sandbox compute sizing. Docker/Podman apply limits; Kubernetes applies matching requests and limits.
255
+
-`--cpu`, `--memory`: Set portable per-sandbox limits. Docker/Podman apply limits. Kubernetes uses a limit as the matching request unless a Kubernetes driver-config request is set; typed API or SDK requests take precedence over driver config.
-`--template NAME`: Create from a named sandbox workload template. Conflicts with inline workload flags such as `--from`, `--gpu`, `--cpu`, `--memory`, `--env`, and `--driver-config-json`.
258
258
-`--label KEY=VALUE`: Add labels for later selection (repeatable)
0 commit comments