-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eos-updater: Add support for OSTree sysroot autocleanup
When OSTree staged deployments are used, the old rollback deployment is deleted during system shutdown. To keep from slowing down shutdown, the OSTree repo is not pruned at that time. That means that even though the deployment was deleted, the objects are still on disk. Since that may be a significant amount of wasted disk space, the full cleanup with repo pruning needs to be run at some time after rebooting. See ostreedev/ostree#2510 for details. To detect when cleanup is necessary, a systemd drop in is added to touch the `/sysroot/.cleanup` file after `ostree-finalize-staged.service` has finalized the new deployment. The reason to use a drop-in for `ostree-finalize-staged.service` rather then creating the file from `eos-updater` is to avoid the situation where an unclean shutdown occurs and the new deployment is not finalized. In that case, cleanup would be run unnecessarily on the next boot. A new systemd service, `eos-updater-autocleanup.service`, is added to run `ostree admin cleanup` when `/sysroot/.cleanup` exists and then delete it afterwards. This adds a dependency on the `ostree` CLI but a separate program could be provided calling the `ostree_sysroot_cleanup` API and deleting the `/sysroot/.cleanup` file itself. https://phabricator.endlessm.com/T5658
- Loading branch information
1 parent
a49c5e9
commit b5c457e
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[Unit] | ||
Description=Automatically cleanup after staged Endless OS Updater deployment | ||
Documentation=man:ostree-admin-cleanup(1) man:eos-updater(8) | ||
|
||
# Run ostree admin cleanup only if /sysroot/.cleanup is present and then | ||
# delete it when cleanup is successful. | ||
# | ||
# FIXME: Drop this when https://github.com/ostreedev/ostree/issues/2510 | ||
# is resolved. | ||
ConditionPathExists=/sysroot/.cleanup | ||
|
||
# We want this to be triggered by multi-user.target but not block it via | ||
# the default After added to target units since pruning the repo can be | ||
# slow. See the Default Dependencies sections in systemd.service(5) and | ||
# systemd.target(5). | ||
DefaultDependencies=no | ||
Requires=sysinit.target | ||
After=sysinit.target basic.target | ||
Conflicts=shutdown.target | ||
Before=shutdown.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@ostree@ admin cleanup | ||
ExecStart=/bin/rm -f /sysroot/.cleanup | ||
|
||
# Only /sysroot and /boot need to be written to. | ||
ProtectSystem=strict | ||
ReadWritePaths=/sysroot /boot | ||
|
||
# This will be allowed to run in the background, so try to make it less | ||
# disruptive while it prunes the repo. | ||
IOSchedulingClass=idle | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is a drop-in file for ostree-finalize-staged.service. | ||
# | ||
# FIXME: Drop this when https://github.com/ostreedev/ostree/issues/2510 | ||
# is resolved. | ||
|
||
[Service] | ||
# After finalizing the staged deployment, touch the .cleanup file so | ||
# that the cleanup can be completed on the next boot. | ||
ExecStop=-/bin/touch /sysroot/.cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters