Repository navigation
Description
Problem and impact
Compensation for an interrupted route switch restores the previous containers using the new release's hostnames. When a deployment changes domains, a failed or cancelled deployment can therefore leave the old release unreachable at its original hostname, even if every compensating agent action succeeds.
Affected revision: 1295e534d7a1c3cd0a492449de8806aa532a4924. Priority: P1, deployment recovery correctness.
Scenario
- Release A serves
old.example.comthroughold-container:3000. - Release B changes the configuration to
new.example.com, using a new container and port. - The deployment fails or is cancelled while switching routes, selecting the
restore_previousrecovery outcome. - Recovery emits an
upsert_routefornew.example.compointing toold-container:3000. It does not restore the previous hostname matcher.
Restoring the backend is insufficient: the route's hostnames are part of the state that must be restored. This scenario does not require another application, a domain-claim race, application deletion, or a failed cleanup action.
Evidence
PipelineContext.previouscontains allocations, while the available release configuration belongs to the current deployment.DeploymentPipeline.loadloads the new release and previous allocations, but not the previous release's route configuration.recoveryobtainshostsfromcontext.release.config, then combines those hosts withcontext.previousupstreams.
A bounded test executed the real recovery() function with different old and new domains. It confirmed that the generated restoration action contained the old container/port and the new domain. This is a verified incorrect action plan; the audit did not run this scenario end to end against a VM and Caddy.
The existing pipeline test's fake route state records upstream containers or a maintenance page, but discards hostname matchers. It cannot establish that the previous route was fully restored.
Proposed correction
Make the previous effective route configuration available to recovery, including hostnames, upstreams and maintenance state. Derive it from immutable release state where sufficient, or persist the necessary before-image before switching. Recovery after a worker restart must reconstruct the same restoration plan rather than reading the edited application configuration.
Acceptance criteria
- A failed or cancelled deployment that changes domains restores the previous hostname matchers and upstream ports; the new hostname is not accidentally attached to the previous release.
- Cover a partial switch across multiple nodes and recovery after a worker restart.
- Preserve maintenance-mode recovery and first-deployment behavior.
- Extend the planner test's fake routing state to retain hostnames, and add a disposable Caddy integration case that requests both old and new hostnames.
- Keep domain reservation retention and audit/idempotency guarantees intact.
Related work, distinct scope
- Closed A removed domain is released while its route still serves traffic #302 and open Keep domain reservations until application-deletion cleanup is confirmed #474 concern when domain reservations may be released. This issue concerns the contents of a restoration action, with no reservation reassignment or application deletion.
- Apply a route switch in one Caddy configuration load #438 concerns applying one route change in a single Caddy configuration load. Even an atomic, successful load cannot fix an action containing the wrong hostnames.
Publication check (2026-11-25): main advanced to 2ee78ff1e96118b1732b98bc54c99f5f91b95a32 through #469, which changes only an exec-session test. The production paths above are unchanged.
Activity
fix(api): a failed route switch restores the previous release's hostn…