Skip to content

bug(cli): tale restore --stop neither refuses nor stops a colour replica that is restarting #4980

Closed

Description

@yannickmonney

Summary

tale restore decides which containers are live with two different tests. A colour replica (backend-api, backend-worker, platform in <id>-blue / <id>-green) whose Docker state is restarting or paused counts as not running, so tale restore neither refuses because of it nor stops it with --stop. Under the unless-stopped restart policy such a replica keeps trying to start while the snapshot is written into the volumes.

Anchors are at main 009f64d141.

What the code does today

  • restore.ts:75-102 findRunningProjectContainers has two branches:
    • the stateful tier and the dev stack, by their pinned names, through isContainerRunning;
    • both colours, by their compose project, through listComposeContainers, keeping only container.running.
  • is-container-running.ts:3-14 reads {{.State.Running}}, which Docker sets for running, restarting and paused alike.
  • list-service-containers.ts:72-96 reads the docker ps -a field {{.State}} and sets running: state === 'running', so restarting and paused are false.
  • restore.ts:177-192 refuses without --stop, or stops each listed name with --stop, only for the names that function returned. The comment above it states the reason: "Restoring under a live stack guarantees corruption".
  • Colour services run with restart: 'unless-stopped' (create-backend-services.ts:80, create-platform-service.ts:25). A replica that exits with an error is restarted by Docker with backoff, and between attempts its state is restarting.

Observed

On Docker 29.6.1 (Docker Desktop, macOS), a stand-in container ran with --restart unless-stopped, the labels com.docker.compose.project=standin-blue and com.docker.compose.service=backend-api, and the command sh -c 'sleep 1; exit 1'. Polled every 0.5 s:

Sample docker ps -a {{.State}} (what listComposeContainers reads) inspect {{.State.Running}}/{{.State.Restarting}} (what isContainerRunning reads)
t=1 running true/false
t=7 restarting true/true

The same container is "running" for one helper and not for the other while it waits to restart.

Not examined

  • A full tale restore --stop against a workspace with a crash-looping colour replica was not run.
  • So the following consequence is derived from the code above, not observed. When the database comes back, for example through the tale deploy --stop that the restore suggests at restore.ts:301-308, the surviving replica's next start runs its boot migrations against the restored data.
  • After the automation writer protocol cutover (fix(cli): let tale deploy cross the automation protocol cutover #4954) this matters more. A protocol-2 replica that survives the restore of a pre-cutover snapshot would apply migration 0163 to it without the cutover barrier, and would put that snapshot's unfinished automation runs on hold.
  • paused was not exercised with the stand-in. The claim about it rests on Docker's state model (State.Running is true while paused).

Constraints any change must respect

  • A restore must never write into the volumes while any process that can reach them may start.
  • Without --stop, a restore refuses and changes nothing. With --stop, it stops what it found and aborts if a stop fails (restore.ts:186-191).
  • docker stop on a restarting container ends the restart loop. unless-stopped then keeps it down, including across a daemon restart.
  • The two helpers have other callers: listComposeContainers (with its running-only wrapper listRunningServiceContainers, list-service-containers.ts:114-122) also serves color-lifecycle.ts, logs.ts and reset.ts, and isContainerRunning serves more than restore; a change to their meaning reaches those callers too.

Options (no preference)

  1. One predicate for restore. Treat every state except exited, created and dead as live for both branches, so the refusal and --stop see the same set.
  2. Stop the colour projects as a whole. Stop or refuse on every container of <id>-blue and <id>-green whatever its state, for example docker compose -p <id>-<colour> stop.
  3. Remove the colour containers before restoring. The restore already asks for a redeploy afterwards, but this drops the previous colour that tale rollback would use.
  4. Name the state in the refusal (for example "<name> is restarting") and keep the stop list as is. This informs the operator but does not close the window.

Questions

  • Should paused count as live for a restore? A paused process holds its connections but cannot act until it is unpaused.
  • Should the same predicate apply to the stateful tier's pinned names, which already count restarting through State.Running?
  • Should a restore that finds a replica of a newer release than the snapshot refuse outright, whatever its state?

Related

Activity

  1. added
    agent-ready
    on Oct 29, 2026
  2. added a commit that references this issue on Oct 30, 2026
    8b356e9
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

    agent-readybugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions