Repository navigation
fix(openshell-provider): plan new objects without reaching the gateway - #13283
Merged
Merged
Conversation
Objects took the gateway data source's ref, which a single root would leave unknown at plan time whenever the read waits for apply, planning objects as changed. They now take the same ref as a literal, known while planning; the gateway reads still gate them through depends_on and a compatibility precondition.
Planning a new OpenShell object connected to its gateway to check that the name wasn't already taken. On a fresh install with one root, the gateway doesn't exist until the same apply installs it, so every first plan would fail. Planning now only validates the gateway ref. reconcile already refuses a name owned by someone else before every mutation, so the ownership check moves to apply.
cv
added a commit
that referenced
this pull request
Oct 15, 2026
…fu root (#13286) Part of #13254. Builds on #13264, #13265, #13282 and #13283, all merged. ## Failure The SDK ran each deployment as two OpenTofu roots: a runtime stage (managed gateway, model servers, storage) and an OpenShell stage (workspace, inference, sandboxes, Fabric agents). Each had its own state, plan, apply, destroy, export and recovery markers. Every operation ran OpenTofu twice, with stage-specific deferrals, markers and rules in between. Hand-written HCL never needed any of that. ## Decision Compile, plan, apply, export and destroy one root, with one state in the deployment's state directory. - **Compilation:** `compile::deployment_graph` merges the runtime graph into the object graph. - **Gateway reads:** the runtime's gateway read, which waits for the gateway it installs, replaces the plan-time read. On a fresh install or a pending gateway change it moves to apply; otherwise it runs at plan. - **Ordering:** every object already waits on the apply-time gateway read, which now waits on every runtime resource and readiness read. So the runtime settles before any object changes, within one apply. A spike with the bundled OpenTofu confirmed that destroy follows the same chain, removing objects before the runtime. - **Plan and apply:** one saved plan, checked against runtime bindings (bound process specifications, retained storage) and object targets together. - **Docker models:** the protection against disrupting a running model applies to that plan. - **Lost creations:** only OpenShell and Fabric creations are recorded, since OpenTofu saves every other ID. After a failed apply, the record forgets creations this apply added but OpenTofu never started; a failure stops OpenTofu before everything that depends on what failed. A creation whose apply started, or whose address OpenTofu didn't report, stays pending, and so does any earlier unresolved one. - **Teardown:** one teardown graph and one destroy, with Helm checkpointing around it as before. The retained workspace binding is required only once OpenShell objects are bound. - **Export:** one refresh-only observation over the single state. - **Removed:** - the runtime stage and its state subdirectory; - the runtime pending and destroy markers; - the gateway-not-running deferral and its message; - `OperationResult::deferred_resources`, and the CLI section that printed it; - the Kubernetes "unfinished platform apply" rule. Per the decisions on #13254: no compatibility work, and a gateway that's down is an ordinary failure. ## Validation - `cargo ci` passes locally: 1527 unit tests, 145 lifecycle tests. - `cargo ci live-docker` passes: 9 tests, including the managed gateway's plan, apply, no-op, destroy and recovery with real Docker and OpenTofu. - **New unit test:** `a_failed_apply_forgets_only_new_creations_it_never_started`. - **Updated tests:** - **Two-stage expectations:** the Helm recovery, remote-service and Kubernetes interruption tests used the second state directory, stage-specific command scripts and runtime-only markers. They now use one state; tests of removed rules are deleted. - **Live tests:** Brev, Spark, hosted parity and the dummy agent now expect one plan that creates runtime and objects together. These need their own hardware and weren't run here. The architecture, apply-flow and state docs still describe two stages; the docs PR for #13254 updates them.
This was referenced Oct 15, 2026
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.
Part of #13254. Stacked on #13282.
Failure
When OpenTofu planned a new OpenShell object, the provider connected to the object's gateway to check that its name wasn't already taken. On its own that was only an early warning. But it stops runtime and OpenShell resources from sharing one root: on a fresh install, the gateway doesn't exist until the same apply installs it, so every first plan would fail. For managed Kubernetes gateways, the connection even opened a port-forward to a pod that doesn't exist yet.
Decision
Planning an OpenShell object reaches no gateway. It still validates the gateway
reflocally; otherwise it does nothing.Ownership checks don't weaken: before every create or update,
reconcilealready observes the live object and refuses a name owned by someone else. A conflicting name now surfaces at apply instead of plan, which is how OpenTofu providers usually behave.Fabric agents keep their plan-time check against their sandbox. It only runs once the sandbox
refis known, by which point the gateway exists.Validation
new_objects_plan_without_reaching_the_gateway: plans standalone HCL whose gateway endpoint has nothing listening. It failed before the change withResource planning failed.cargo cipasses locally: 1539 unit tests, 145 lifecycle tests.docs/provider.mdsays where ownership is checked.