Skip to content

Restore previous release domains when compensating a route switch #485

Done

Description

@samuelmbabhazi

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

  1. Release A serves old.example.com through old-container:3000.
  2. Release B changes the configuration to new.example.com, using a new container and port.
  3. The deployment fails or is cancelled while switching routes, selecting the restore_previous recovery outcome.
  4. Recovery emits an upsert_route for new.example.com pointing to old-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.previous contains allocations, while the available release configuration belongs to the current deployment.
  • DeploymentPipeline.load loads the new release and previous allocations, but not the previous release's route configuration.
  • recovery obtains hosts from context.release.config, then combines those hosts with context.previous upstreams.

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

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

  1. added
    bug
    priority:P1
    v0.1-stable
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P1track:control-planev0.1-stable

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions