feat(docker): add opt-in boot and shutdown units for hosts that run Docker with live-restore #371
Open
Dragonish
wants to merge 1 commits from
feat/369-docker-boot-shutdown-units into main
pull from: feat/369-docker-boot-shutdown-units
merge into: Mortis:main
Mortis:main
Mortis:docs/136-role-readme-headings
Labels
Clear labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Status
Needs Triage
Maintainer needs to evaluate this issue
Status
Ready for Agent
Fully specified, ready for an AFK agent
Status
Ready for Human
Requires human implementation
Wayfinder
Grilling
Decision ticket resolved in conversation with the maintainer
Wayfinder
Map
Wayfinder map: index of a planning effort and its decision tickets
Wayfinder
Prototype
Decision ticket resolved by reacting to a rough concrete artifact
Wayfinder
Research
Decision ticket resolved by reading outside sources
Wayfinder
Task
Manual work that must happen before a decision can be made
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mortis/Kamino#371
Reference in new issue
Block a user
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
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.