Skip to content

Commit bf311af

Browse files
authored
feat(docker): preserve workspace storage during stopped image updates (#5617)
* feat(docker): add opt-in persistent workspace storage Refs #5484. Keep workspace data separate from disposable runtime resources, validate retained volume identity, and preserve legacy layouts. Workload image replacement and native qualification remain separate work. Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * feat(docker): add stopped workload replacement component Refs #5484. Preserve native identity and recorded data volumes while replacing workload bytes and refreshing container-bound runtime evidence. Keep update capability negotiation disabled pending lifecycle/restart integration and native qualification. Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * feat(docker): integrate stopped image updates with lifecycle recovery Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * fix(gateway): keep single-driver feature selections lint clean Name the feature-selected registration array before iteration so Clippy does not flag the supported Docker-only build as a single-element loop. Driver entries, ordering and registration behavior remain unchanged. Validation: cargo fmt --all --check and Docker-only gateway Clippy with compute-driver-docker, telemetry and vendored-z3, all targets and warnings denied. Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * fix(docker): validate update identity and repair launch rotation Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * fix(docker): preserve legacy labels and qualify image updates Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> * fix(docker): record workspace ownership in protected driver state Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> --------- Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
1 parent eabc6da commit bf311af

22 files changed

Lines changed: 4470 additions & 78 deletions

File tree

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,19 @@ Use `mise run e2e:kubernetes` for the standard Helm-backed Kubernetes suite.
447447
Set `OPENSHELL_E2E_KUBE_TEST=kubernetes_image_update` to scope the Rust suite to
448448
combined image, command, environment, and metadata updates with retained sandbox,
449449
SSH, and PVC identities. The next start verifies the new argv and environment. This target is
450-
included in both existing Agent Sandbox API-version lanes; unlike the Python
451-
Docker suite, it exercises the driver that supports image updates.
450+
included in both existing Agent Sandbox API-version lanes. Docker separately
451+
supports image-only updates on stopped, opt-in persistent `/sandbox` workspaces;
452+
this Kubernetes lane does not qualify that path. Docker requires locally cached
453+
images, a matching numeric target `USER UID:GID`, and no image-declared volumes.
454+
Do not treat a skipped Docker lane as live image-replacement coverage.
455+
456+
The separate `docker-updates` testkit suite qualifies the full Docker path
457+
through an owned mTLS gateway, including SSH exec, image replacement, restart,
458+
credential-publication repair and deletion. Follow
459+
`tests/suites/features/docker-updates/README.md`; the wrapper's
460+
`OPENSHELL_E2E_DOCKER_IMAGE_UPDATES=1` opts in only its fresh gateway and refuses
461+
an existing endpoint. On Docker Desktop without host networking, select the
462+
documented bridge override rather than changing engine settings.
452463

453464
Image updates default to disabled outside test fixtures. The e2e wrapper opts
454465
in only for a fresh gateway fixture that it owns; set

‎crates/openshell-driver-docker/README.md‎

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,89 @@ New generations require matching supervisor and sandbox runtime binaries.
128128

129129
## Stop, Start, and Delete
130130

131+
Set `persist_workspace = true` in `[openshell.drivers.docker]` to give newly
132+
created default `/sandbox` workspaces a driver-owned local volume. The setting
133+
defaults to false and does not migrate existing writable-layer workspaces.
134+
Custom working directories and image-declared volumes overlapping `/sandbox`
135+
are rejected when enabled. Initialization prepares the workspace ownership;
136+
it does not copy the image's workspace contents into the volume.
137+
138+
The driver records and rechecks the volume identity and workload UID/GID before
139+
restart, including when external resource admission is disabled. Stop retains
140+
the data. Explicit sandbox deletion removes the owned workspace volume and
141+
reports removal failures. Startup orphan cleanup retains workspace volumes
142+
without a workload; an interrupted create requires explicit recovery/removal.
143+
This option advertises the optional workload update capability. The gateway's
144+
separate `enable_sandbox_updates` setting must also be enabled to accept updates.
145+
146+
Persistence ownership comes from `workspace-storage.json` in the protected
147+
per-sandbox driver directory, bound into the private bootstrap and runtime
148+
descriptor. It records the namespace, sandbox, workload UID/GID and exact volume
149+
identity. Container labels do not select persistent storage or authorize volume
150+
admission, updates or removal. All caller template labels retain their existing
151+
meaning, including generic and Docker-specific workspace label names.
152+
153+
### Stopped Workload Image Updates
154+
155+
The Docker updater implements the existing configuration-update RPC for
156+
image-only changes on stopped, persistent `/sandbox` workspaces. Source and
157+
target images must already be cached locally and declare no image volumes. The
158+
target must declare an explicit numeric `USER UID:GID` matching the recorded
159+
non-root workload identity. Symbolic users/groups, UID-only users, and an absent
160+
`USER` are rejected before replacement; update preflight does not resolve image
161+
accounts. Command and environment changes are unsupported.
162+
163+
The update replaces the stopped workload container while preserving the native
164+
sandbox ID and owned workspace volume. It refreshes the private runtime evidence
165+
for the replacement; it does not change the trusted sandbox or supervisor images.
166+
A private operation record lets the same accepted operation resume after an
167+
interruption. Start refuses an unfinished update. Stop and startup reconciliation
168+
retain its data and runtime resources; explicit Delete removes its owned storage.
169+
Retry through the gateway to finish the accepted update before starting it.
170+
The operation never starts the workload or rolls back workspace data implicitly.
171+
172+
#### Live Driver Integration Test
173+
174+
The opt-in test below uses a real Docker daemon and isolated, uniquely labeled
175+
stopped containers and a workspace volume. It checks numeric/symbolic identity
176+
refusal, A-to-B replacement, retained file bytes, replay, and recovery after an
177+
accepted update loses its source container. Cleanup verifies ownership and never
178+
forces removal. This is driver integration coverage; gateway authorization,
179+
supervisor startup, and authenticated workload operations still require E2E.
180+
181+
From the repository root, prepare the four local test images:
182+
183+
```shell
184+
for version in A B BAD SYMBOLIC; do
185+
case "$version" in
186+
BAD) fixture_user=2000:2000 ;;
187+
SYMBOLIC) fixture_user=other:other ;;
188+
*) fixture_user=1234:1235 ;;
189+
esac
190+
docker build --network=none --build-arg VERSION="$version" \
191+
--build-arg WORKLOAD_USER="$fixture_user" -t "openshell-image-update-test:$version" \
192+
crates/openshell-driver-docker/tests/fixtures/image-update
193+
done
194+
195+
OPENSHELL_DOCKER_UPDATE_IMAGE_A=openshell-image-update-test:A \
196+
OPENSHELL_DOCKER_UPDATE_IMAGE_B=openshell-image-update-test:B \
197+
OPENSHELL_DOCKER_UPDATE_IMAGE_BAD=openshell-image-update-test:BAD \
198+
OPENSHELL_DOCKER_UPDATE_IMAGE_SYMBOLIC=openshell-image-update-test:SYMBOLIC \
199+
cargo test --locked -p openshell-driver-docker --lib \
200+
live_stopped_image_replacement -- --ignored --nocapture
201+
```
202+
203+
The Docker CLI must be on `PATH` and use the same daemon as the SDK. On Docker
204+
Desktop, set `DOCKER_HOST` to the socket reported by `docker context inspect`.
205+
206+
For authenticated gateway/supervisor qualification, including SSH exec,
207+
replacement, gateway restart, interrupted credential-publication repair and
208+
complete API deletion, run the separate
209+
[Docker update testkit suite](../../tests/suites/features/docker-updates/README.md).
210+
131211
Stop terminates the supervisor companion, allowing it 10 seconds to stop the
132-
workload, and stops the workload container without removing it. Docker retains the workload writable layer and attached
212+
workload, and stops the workload container without removing it. Docker retains
213+
the workload writable layer and attached
133214
volumes. Start stages a fresh sandbox bootstrap bundle, restarts that workload,
134215
and creates a new supervisor companion. A durably stopped sandbox stays stopped
135216
across gateway restarts.

0 commit comments

Comments
 (0)