Skip to content

After a restore, the next deployment of an application deployed since the backup fails without a reason and leaves its container running #501

Done

Description

@samuelmbabhazi

What happens

After a restore (backup.sh restore, ADR 0026), the control plane is back at the time of the backup, but the servers still run what was deployed after it. For an application deployed in between:

  1. Its next deployment fails at createContainer, which is compensated. The deployment says Step create compensated: action failed. The timeline's action has reason: null, and the agent logs nothing.
  2. A second attempt succeeds. The container of the lost deployment keeps running, unknown to the control plane, and nothing removes it.

Reproduction

Found while verifying the published v0.1.0-alpha.5 for #480. Reproduced twice in test containers (Ubuntu 24.04 with systemd):

  • single machine on alpha.5, with an alpha.5 agent;
  • alpha.3 upgraded to alpha.5, with a separate server on an alpha.3 agent.
  1. Deploy an application. Its release is n, its container sk-<app>-r<n>-0.
  2. sudo ./backup.sh create b.age.
  3. Deploy it again: release n+1, container sk-<app>-r<n+1>-0, still running.
  4. printf 'replace\n' | sudo ./backup.sh restore b.age identity.txt, then sign in again.
  5. Deploy again. The restored database gives this release the number n+1 again, and the container name already exists with another specification. The agent refuses with errSpecConflict ("container exists with a different specification", agent/internal/actions/container.go), and the step is compensated.
  6. Deploy once more: release n+2 succeeds. sk-<app>-r<n+1>-0 is still up, and still uses its share of the server.

What the database showed in the alpha.3 lab: before the restore it had releases 1 and 2, after it release 1 only, and the next release was numbered 2 again.

Why it matters

This is the case a restore is for: nightly backups, deployments during the day, the machine is lost, and its backup is restored on a new one. Every application deployed since that backup fails its next deployment without a reason, and leaves a container nobody tracks.

Possible directions

  • Show the agent's cause. The agent knows it; the control plane shows action failed with no reason. This is worth doing whatever else is chosen.
  • Keep names apart: derive container names from the release id rather than its number, so a restored database never reuses a live name. That avoids the failure, but not the untracked container.
  • Reconcile after a restore: agents already report their containers. Containers of a known application that belong to no known release could be reported, then removed or adopted. Release numbering could also resume after the highest number a server reports.

The last one is a design change (what the control plane trusts after a restore). It probably needs an ADR, or an addition to ADR 0026.

Until then

INSTALL.md (Back up and restore) will say that a deployment made after the backup leaves its container running, and that the next deployment of that application fails once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P2track:cross-cutting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions