Adds two opt-in inputs to the docker role for a host that runs Docker with live-restore. Both default to false, so a host that does not set them is unchanged.
docker_start_missed (with docker_start_missed_settle_seconds): a boot unit, docker-start-missed.service, starts the containers dockerd's restore pass skipped after a reboot of the whole host. It starts a container only if its restart policy is unless-stopped or always, it exited with code 255, and it finished after this boot began, so a container stopped on purpose stays stopped. Type=simple, so it never delays or fails the boot.
docker_stop_at_shutdown (with docker_stop_at_shutdown_timeout): a RemainAfterExit unit whose stop action runs at shutdown after docker.service has stopped and before the network and remote file systems. It sends SIGTERM to every container process, waits up to the timeout, then SIGKILL. It never calls docker stop or docker kill (both set the manually-stopped marker). The role starts the unit, because systemd runs a stop action only for an active unit.
Both units carry ConditionPathExists=/usr/bin/docker, are installed only on a host the docker role is applied to, and are removed when their input goes back to false or with docker_remove. The role never stops a running shutdown unit, because stopping it runs its stop action and ends every container. Both scripts are in roles/docker/files/.
Both scripts are commands installed on the host and run by systemd, so ansible-test sanity rejects their shebang as non-module: two entries with that reason are added to tests/sanity/ignore-common.txt (under CODEOWNERS, so they need your review).
pre-commit hooks on the commit: yamllint, ruff, shellcheck, REUSE, changelog fragment lint, ansible-lint, conventional commit, agent trailer.
python3 -m unittest discover -s tests/scripts -p 'test_docker_files.py': 23 tests, covering which containers docker-start-missed selects (policy, exit code, finish time against the boot time, nanosecond timestamps, restarting and never-started containers), its exit codes when Docker fails or answers oddly, and that docker-stop-at-shutdown has no docker stop or docker kill outside comments.
The process listing of the shutdown script on a fake cgroup tree: PID 0 is dropped, processes in child cgroups are included.
An independent read-only review of this diff; its findings (a Molecule task that could signal the wrong processes, PID 0, child cgroups, the boot ordering, unproven claims about when a changed unit takes effect) are fixed in this commit.
The Molecule scenario is extended (units installed, enabled, ordered against docker.service, shutdown unit active, timeout in the unit, a unit removed when its input is false, removal with docker_remove, docker_stop_at_shutdown_timeout: 0 refused). Its result is the Molecule check on this PR.
Not verified
What the units do at a real boot or shutdown. The Molecule container has no dockerd, no NFS shares and no reboot, and the shutdown script is not run there because the container shares the runner's cgroup tree. An earlier version of the shutdown unit, before the review fixes in this commit, ran on a Docker host with live-restore outside this repository: a shutdown that took 181.6 s with a container holding NFS mounts took about 8 s with it. The version in this PR was not run there.
What systemd does with an active unit whose file is removed or changed. The role never stops it, and the docs say so without claiming more.
The shutdown script reads the systemd cgroup driver's layout on cgroup v2. On another layout it finds nothing and logs that; this is stated in the README.
Ordering the shutdown unit before docker.service also applies at boot (Docker waits for network-online.target and remote-fs.target). Documented, not measured.
I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.
Assisted-by: Claude Code
## What and why
Adds two opt-in inputs to the `docker` role for a host that runs Docker with `live-restore`. Both default to `false`, so a host that does not set them is unchanged.
- `docker_start_missed` (with `docker_start_missed_settle_seconds`): a boot unit, `docker-start-missed.service`, starts the containers dockerd's restore pass skipped after a reboot of the whole host. It starts a container only if its restart policy is `unless-stopped` or `always`, it exited with code 255, and it finished after this boot began, so a container stopped on purpose stays stopped. `Type=simple`, so it never delays or fails the boot.
- `docker_stop_at_shutdown` (with `docker_stop_at_shutdown_timeout`): a `RemainAfterExit` unit whose stop action runs at shutdown after `docker.service` has stopped and before the network and remote file systems. It sends SIGTERM to every container process, waits up to the timeout, then SIGKILL. It never calls `docker stop` or `docker kill` (both set the manually-stopped marker). The role starts the unit, because systemd runs a stop action only for an active unit.
Both units carry `ConditionPathExists=/usr/bin/docker`, are installed only on a host the `docker` role is applied to, and are removed when their input goes back to `false` or with `docker_remove`. The role never stops a running shutdown unit, because stopping it runs its stop action and ends every container. Both scripts are in `roles/docker/files/`.
Both scripts are commands installed on the host and run by systemd, so `ansible-test sanity` rejects their shebang as non-module: two entries with that reason are added to `tests/sanity/ignore-common.txt` (under `CODEOWNERS`, so they need your review).
Closes #369
## Verified
- `pre-commit` hooks on the commit: yamllint, ruff, shellcheck, REUSE, changelog fragment lint, ansible-lint, conventional commit, agent trailer.
- `python3 -m unittest discover -s tests/scripts -p 'test_docker_files.py'`: 23 tests, covering which containers `docker-start-missed` selects (policy, exit code, finish time against the boot time, nanosecond timestamps, restarting and never-started containers), its exit codes when Docker fails or answers oddly, and that `docker-stop-at-shutdown` has no `docker stop` or `docker kill` outside comments.
- The process listing of the shutdown script on a fake cgroup tree: PID 0 is dropped, processes in child cgroups are included.
- An independent read-only review of this diff; its findings (a Molecule task that could signal the wrong processes, PID 0, child cgroups, the boot ordering, unproven claims about when a changed unit takes effect) are fixed in this commit.
- The Molecule scenario is extended (units installed, enabled, ordered against `docker.service`, shutdown unit active, timeout in the unit, a unit removed when its input is `false`, removal with `docker_remove`, `docker_stop_at_shutdown_timeout: 0` refused). Its result is the Molecule check on this PR.
## Not verified
- What the units do at a real boot or shutdown. The Molecule container has no dockerd, no NFS shares and no reboot, and the shutdown script is not run there because the container shares the runner's cgroup tree. An earlier version of the shutdown unit, before the review fixes in this commit, ran on a Docker host with `live-restore` outside this repository: a shutdown that took 181.6 s with a container holding NFS mounts took about 8 s with it. The version in this PR was not run there.
- What systemd does with an active unit whose file is removed or changed. The role never stops it, and the docs say so without claiming more.
- The shutdown script reads the systemd cgroup driver's layout on cgroup v2. On another layout it finds nothing and logs that; this is stated in the README.
- Ordering the shutdown unit before `docker.service` also applies at boot (Docker waits for `network-online.target` and `remote-fs.target`). Documented, not measured.
---
- [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none.
Assisted-by: Claude Code
docker_start_missed installs a boot unit that starts the containers dockerd's
restore pass skipped after a reboot of the whole host. docker_stop_at_shutdown
installs a unit that ends container processes at shutdown while the network and
NFS shares are still up, so a container holding an NFS mount no longer stalls
the shutdown. Both default to false and do nothing without /usr/bin/docker.
Refs #369
Assisted-by: Claude Code
CODEOWNERS rules
requested review from Defame1297 2026-11-25 17:32:31 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What and why
Adds two opt-in inputs to the
dockerrole for a host that runs Docker withlive-restore. Both default tofalse, so a host that does not set them is unchanged.docker_start_missed(withdocker_start_missed_settle_seconds): a boot unit,docker-start-missed.service, starts the containers dockerd's restore pass skipped after a reboot of the whole host. It starts a container only if its restart policy isunless-stoppedoralways, it exited with code 255, and it finished after this boot began, so a container stopped on purpose stays stopped.Type=simple, so it never delays or fails the boot.docker_stop_at_shutdown(withdocker_stop_at_shutdown_timeout): aRemainAfterExitunit whose stop action runs at shutdown afterdocker.servicehas stopped and before the network and remote file systems. It sends SIGTERM to every container process, waits up to the timeout, then SIGKILL. It never callsdocker stopordocker kill(both set the manually-stopped marker). The role starts the unit, because systemd runs a stop action only for an active unit.Both units carry
ConditionPathExists=/usr/bin/docker, are installed only on a host thedockerrole is applied to, and are removed when their input goes back tofalseor withdocker_remove. The role never stops a running shutdown unit, because stopping it runs its stop action and ends every container. Both scripts are inroles/docker/files/.Both scripts are commands installed on the host and run by systemd, so
ansible-test sanityrejects their shebang as non-module: two entries with that reason are added totests/sanity/ignore-common.txt(underCODEOWNERS, so they need your review).Closes #369
Verified
pre-commithooks on the commit: yamllint, ruff, shellcheck, REUSE, changelog fragment lint, ansible-lint, conventional commit, agent trailer.python3 -m unittest discover -s tests/scripts -p 'test_docker_files.py': 23 tests, covering which containersdocker-start-missedselects (policy, exit code, finish time against the boot time, nanosecond timestamps, restarting and never-started containers), its exit codes when Docker fails or answers oddly, and thatdocker-stop-at-shutdownhas nodocker stopordocker killoutside comments.docker.service, shutdown unit active, timeout in the unit, a unit removed when its input isfalse, removal withdocker_remove,docker_stop_at_shutdown_timeout: 0refused). Its result is the Molecule check on this PR.Not verified
live-restoreoutside this repository: a shutdown that took 181.6 s with a container holding NFS mounts took about 8 s with it. The version in this PR was not run there.docker.servicealso applies at boot (Docker waits fornetwork-online.targetandremote-fs.target). Documented, not measured.NOTICEandREUSE.toml, or there is none.Assisted-by: Claude Code