fix: Wait for one-shots before a rolling swap #95
No reviewers
Labels
No labels
priority/P0
priority/P1
priority/P2
priority/P3
size/L
size/M
size/S
size/XL
size/XS
state/blocked
state/done
state/in-progress
state/in-review
state/needs-refinement
state/ready
type/bug
type/chore
type/feature
type/refactor
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
amtronics/platform-actions!95
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/94-wait-one-shots"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue
Closes #94
Problem
In rolling mode the swap runs with
--no-deps. A new replica can therefore start while a migration it depends on is still running, or after that migration has failed. Without rolling, compose'sservice_completed_successfullyprevents this. It blocks suhba/rihla#417.Solution
Before any swap, every recreated container whose restart policy is
nomust exit 0. A timeout or non-zero exit fails the deploy with the one-shot's logs, and the old replicas are left untouched. The README states the rule, including that a long-running service must set arestartpolicy.Review notes
--no-depsre-runs a migration that has already exited;up --waitreports a running one-shot as healthy.Risks and trade-offs
In rolling mode, a non-rolled service with no
restartpolicy (Docker's default isno) is now treated as a one-shot. If it is actually long-running, the deploy fails afterhealth-timeout. No current consumer setsrolling-serviceswith such a service: suhba-web's mail isalways.Verified on
406c972d: the wait sits inside the rolling block afterOTHERSis recreated with--force-recreate --no-depsand before the first--scale, so a one-shot is always this deploy's container and the swap cannot start before it exits 0; a timeout or non-zero exit prints the container's logs and exits before any--scaleorstop.OTHERSis built fromconfig --services, so the non-rolling path is untouched (#94 AC3). Behaviour suite passes locally; the kill case fails against a mutant that ignores the exit code, and the long-running case fails against one that skips the restart-policy check. README states the rule. CI green.Blocking:
fix: Wait for one-shots before a rolling swap(45).Notes, not blocking:
!= "exited"→ never true) passes the whole suite, because the stub always answersexited. A case withState.Statusrunningwould needdatestubbed, which the suite does not do yet, so this is a follow-up, not a fix here.restart: on-failureis not waited for (policy is notno). The README rule is unambiguous, so fine; worth a word there if a consumer ever does that.fix: Wait for one-shot services before a rolling swapto fix: Wait for one-shots before a rolling swap406c972df1982bdba2caRe-review of
982bdba2against review 1703. The PR diff is byte-identical to the one reviewed on406c972d; only the title and commit subject changed, both now 45 chars. CI green on this head. The two non-blocking notes (no still-running case,on-failurepolicies) stand as a follow-up.