Repository navigation
feat(sdk): restart Docker gateways after the gateway or host restarts - #13265
Merged
Merged
Conversation
Generated graphs started the Docker gateway with restart policy no, so a host reboot left it down until the next apply. The gateway now uses unless-stopped; an explicit docker stop still keeps it stopped. Inference containers and the Podman gateway keep no.
Contributor
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.
Closed
8 tasks
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. Part of #13131.
Failure
Generated graphs start the Docker gateway with restart policy
no. After a host reboot or a gateway crash, the gateway stays down until someone applies again. Until then, plans can't refresh the OpenShell resources, which is why the two-stage apply has a gateway restore step. #13254 wants that recovery to be an exception rather than part of every apply.Decision
The Docker gateway container gets the restart policy
unless-stopped.docker stopstays stopped.nocame from the inference containers, where a protective stop under memory pressure must not become a restart loop (docs/design/runtime.md). That reason doesn't apply to the gateway. Managed vLLM, Ollama, and the Ollama proxy keepno.no. Rootless Podman only restarts containers at boot through a systemd unit, so the policy alone wouldn't help there.Validation
restart = "unless-stopped"on the generated gateway. It failed before the change.cargo cipasses locally (1540 unit tests, 144 lifecycle tests).restartfromnotounless-stoppedplanned an in-place update (0 to add, 1 to change, 0 to destroy). The applied container then reportedunless-stopped.docker stop, which this policy respects.