Repository navigation
fix(openshell-provider): let explicit teardown delete workspaces - #13262
Merged
Merged
Conversation
Workspaces were always retained, so a hand-written configuration could not be torn down even with destroy = true. OpenTofu's prevent_destroy already retains a workspace, and generated graphs set it. A workspace now has a sandbox's protection: explicit teardown may delete it, and replacement is still refused. The backend deletes workspaces through DeleteWorkspace, the test fixtures support workspace and volume deletion, and the travel example documents and tests its teardown.
cv
enabled auto-merge (squash)
October 15, 2026 11:57
Contributor
cv
added a commit
that referenced
this pull request
Oct 18, 2026
…pplied (#13408) Closes #13005. ## Failure Running `model_live` on a DGX Spark (GB10) for #13005 found a regression from #13286. After `nemoclaw destroy`, re-applying the same configuration with a managed gateway failed at its first plan with `observation transport failed`: - Destroy removed the managed gateway's container but kept `openshell_workspace.deployment` in state. - With one OpenTofu root, the next plan refreshes that workspace before anything can reinstall the gateway. - #13286 had removed the old deferral for a stopped gateway, so nothing covered this case. The lifecycle tests didn't catch it, because the fixture gateway never goes away. `model_live` also had stale assertions: a retained `vllm_credential_storage`, which exists only with authentication, and a recovery check filtering on the removed `nemoclaw_` prefix. ## Decision - **Destroy deletes the workspace.** SDK destroy now keeps only data (gateway storage, model caches, credentials) and deletes the workspace with the deployment's other objects, as explicit HCL teardown does since #13262. The workspace lives in the gateway destroy removes, and by then its sandboxes, registrations and agents are gone. Re-applying reinstalls a managed gateway on its retained storage and recreates the workspace. - **CLI output:** destroy's "Retaining the workspace does not preserve sandbox files" warning is removed, since the workspace is no longer retained. - **`model_live`:** after destroy it expects the gateway storage and the model cache volume, and through recovery it checks that `openshell_*` and `docker_volume.*` identities are preserved. - **Docs:** `state.md`, `usage.md`, `provider.md` and the CLI reference describe the new retention. ## Validation - The teardown unit tests failed before the change and pass after. Lifecycle tests now expect no workspace after destroy, and a recreated one on re-apply. - `cargo ci` passes locally: 1552 unit tests and 153 lifecycle tests. - On a DGX Spark, with `examples/spark/vllm.yaml` adapted to Deep Agents, because OpenClaw is blocked by #13372: - `model_live::selected_model_apply_export_and_watchdog_recovery_preserve_data_and_identity` passes (658 s); - `model_live::selected_model_continues_from_retained_state` then re-applies the same configuration against the retained state and passes (317 s). Before this change it failed at its first plan.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13230. Part of #13131.
Failure
A hand-written configuration that creates an
openshell_workspacecouldn't be torn down.tofu destroy -var destroy=truerefused the workspace ("workspaces must be retained"), even though OpenTofu already has a configurable way to keep a resource,lifecycle { prevent_destroy = true }, which generated graphs set on their workspaces. The provider's own refusal duplicated that, and left hand-written configurations without a supported teardown.Decision
destroy = true, and replacement is still refused. Keeping a workspace is expressed withprevent_destroy. Generated graphs keep setting it, and the SDK's teardown keeps declaring the workspace, so SDK deployments still retain theirs.DeleteWorkspace, with the same identity check before sending.removeaccepts a retained workspace when destroying.destroy = true; an always-retained resource says it can't be deleted.DeleteWorkspace, refusing a workspace that still holds objects as OpenShell does. The SSH Docker simulator deletes volumes.tofu destroy -var destroy=true, anddocs/provider.mddescribes the workspace lifecycle andprevent_destroy.Validation
travel_examplenow ends with teardown.tofu destroywithoutdestroy = truefails and leaves the sandbox in place; with it, the workspace and every other object are removed. The new steps failed before the change.cargo cipasses locally: 1538 unit tests and 144 lifecycle tests.cargo ci live-dockerpasses locally, including the SDK teardown tests, which still retain their workspaces.