Repository navigation
fix(server): retain sandboxes across compute driver changes - #5133
vineethsai7 wants to merge 2 commits into
Conversation
Signed-off-by: Vineeth Sai Narajala <vnarajal@cisco.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
I have read the DCO document and I hereby sign the DCO. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ec6696ec2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Vineeth Sai Narajala <vnarajal@cisco.com>
Summary
Keep sandboxes created by another compute driver when a gateway's
compute_driverchanges. The gateway records each sandbox's creating driver, leaves foreign records in their persisted phase, and shows why they are unavailable until the original driver is selected again.Related Issue
Closes #4769
Supersedes #5071 (auto-closed before the vouch)
Changes
internal.openshell.ai/created-by-compute-driverfor every new sandbox. The existinginternal.openshell.ai/compute-driverannotation remains the sandbox authentication binding and is used as a fallback for older authenticated records. Records with neither annotation retain their existing reconciliation behavior.Ready=Falsecondition with reasonComputeDriverMismatchto get, list, and watch responses. The CLI list displays the reason. The stored phase and conditions remain unchanged, so switching back restores the sandbox's prior view.Review findings from #5071
Provisioning,Starting, and an expired record.Ready,Stopping, andSuspendingrecords.Release Notes
Changing a gateway's compute driver keeps sandboxes created by its previous driver.
openshell sandbox listshows the mismatch; start, stop, exec, and configuration updates refuse those sandboxes until you switch back. Deleting a foreign sandbox removes only its gateway record.Testing
Checks appropriate to the affected code and behavior pass.
Unit tests added/updated.
E2E tests added/updated.
cargo fmt -p openshell-server -p openshell-cli -- --check: passed on dc-build-1.cargo clippy -p openshell-server -p openshell-cli --features vendored-z3 --all-targets -- -D warnings: passed on dc-build-1.cargo test -p openshell-server -p openshell-cli --features vendored-z3 --lib -- --test-threads=8: passed on dc-build-1 (400 CLI tests and 2,617 server tests; zero failures, 38 server tests ignored).python3 tasks/scripts/check_docs_nav.py: passed.npx --yes fern-api@5.112.0 check --warningsfromfern/: zero errors, three existing warnings (MDX syntax elsewhere on the configuration page, unauthenticated redirect check, and theme contrast).No driver-switch E2E run was performed for this branch.
Checklist
Review follow-up
1621b43efccd322afcc2ae9303e2bc452052ec7e. The gateway checks driver ownership before accepting a supervisor reconnect and before session state, exit/finalize, configuration, policy, endpoint, or provider readiness callbacks can change state. The reconnect/exit regression fails on the original code and passes with the fix.1621b43efccd322afcc2ae9303e2bc452052ec7e. Explicit record-only deletion bypasses the old driver's pending-operation interlocks at both theDeletingtransition and final record removal. Request identity and resource-version preconditions remain enforced; the active driver receives no delete call. The pending-operation regression fails on the original code and passes with the fix.1621b43efccd322afcc2ae9303e2bc452052ec7e.CreateSshSessionandForwardTcpcheck driver ownership before opening a relay. The relay regression fails on the original code and passes with the fix.Follow-up checks on the build box:
cargo fmt -p openshell-server -- --checkpassed;cargo clippy -p openshell-server --features vendored-z3 --all-targets -- -D warningspassed;cargo test -p openshell-server --features vendored-z3 --lib -- --test-threads=4passed (2,619 passed, 38 ignored). An 8-thread repeat had one unrelated intermittent workspace-authorization audit test failure; that test passed alone and the complete 4-thread run passed.The driver-switch E2E scenarios were not run on the build box because it has no KVM, Docker, or mise. The lead runs manual E2E on a real host separately.
Manual verification
PR: NVIDIA/OpenShell #5133 (fix/4769-keep-other-driver-sandboxes-v2), head
1621b43efc.Before: upstream main
be5e49499(openshell 0.1.7-dev.40+gbe5e49499). After: the PR head.Environment
allow_unauthenticated_users). No host OpenShell service was involved.cargo build --release); supervisor and sandbox runtime are local images set assupervisor_imageandsandbox_runtime_imagefor both drivers. Gateway and CLI ran on RHEL 9 through an Ubuntu 24.04 glibc loader.Steps
Before (main)
The gateway restarted with the podman driver listed
osp-keepasStoppedat first. The periodic store/backend reconciliation then did not find it in the podman driver and removed the record:The stopped sandbox from driver A was deleted from the gateway about six minutes after the switch (one reconcile sweep after the 5-minute orphan grace), leaving its container behind with no record.
After (PR head)
Result
PASS. With the PR, the stopped sandbox created by the docker driver is kept after the gateway is switched to podman: it is listed with a clear
ComputeDriverMismatchreason, refuses start under the wrong driver, survived nine minutes of reconciliation, and starts and runs a command again after the gateway is switched back to docker. On main it was deleted from the gateway after about six minutes.Only the docker-then-podman direction was run (a stopped sandbox, the case in the issue). Podman-then-docker was not run.
Second run: macOS, VM driver to Docker driver
Result: PASS (with a limit: the second driver was Docker on a forwarded remote daemon, and no Docker sandbox was created)
Environment
socket_path) at a private forwarded unix socket of a real Docker daemon (Docker 29.1.3, linux/amd64) on another machine. The driver connected, pulled its runtime images and reportedCompute driver connected configured_driver=docker. No Docker sandbox container was created or run (the daemon is amd64 and the host is arm64); the test only needs the gateway to run with the other driver selected.mainatbe5e49499. After: PR head1621b43efc(fix(server): fence foreign sandbox callbacks and pending deletes). Gateway, VM driver and CLI built on the host (Rust 1.95.0, release); for the PR the CLI was built from the PR head too, since the listREASONcolumn is a CLI change.Steps (same before and after)
compute_driver = "vm";openshell sandbox create --name v1 --from ubuntu:24.04 -- sleep 3000in the background; wait untilv1is Ready.v1:stopped=1 failed=0).compute_driver = "docker". Runopenshell sandbox listandsandbox get v1; for the PR also trysandbox start,execandstoponv1.compute_driver = "vm"; list and exec intov1.Before (main,
be5e49499)Starting the Docker-driver gateway treats the VM sandbox as a lost Docker resource and writes that into its record:
Switching back to the VM driver does not recover it: after the second start
v1is stillPhase: Error,BackendResourceMissing, and the VM driver does not start it.After (PR head,
1621b43efc)With the Docker driver selected the sandbox is kept, left in its stored phase, and marked as unavailable with a clear reason; nothing is sent to the Docker driver for it:
Start and stop are refused with a precondition error that names both drivers, and exec is refused while the sandbox is not Ready:
Switching back to the VM driver restores it with no manual step: the start sweep restarts it (
started=1 missing_backend=0 failed=0),v1lists asReadywith no reason, andexecworks:Result
PASS. Main marks the VM sandbox Error (BackendResourceMissing) when the driver changes and never recovers it; the PR head keeps it, shows
ComputeDriverMismatch, refuses operations with a clear message, and the sandbox is fully usable after switching back.Not covered: a Docker-created sandbox seen from a VM-driver gateway (the reverse direction; the Docker driver could not run sandboxes here), the Podman and Kubernetes drivers, deleting a foreign sandbox, and the other background paths the PR lists (deadline expiry, automatic restart); those are unit-tested in the PR. Suggested for the Linux lane if it has Docker and a VM driver on the same host.