-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contrib/systemd: use multi-user.target instead of default.target #24524
base: main
Are you sure you want to change the base?
Conversation
The systemd documentation[1] says the following about using `default.target` as `WantedBy=` in service files: For typical unit files please set "WantedBy=" to a regular target (like multi-user.target or graphical.target), instead of default.target, since such a service will also be run on special boots like on system update, emergency boot ... The mentioned "system update" special boots refer to `systemd.offline-updates`[2] a mechanism that enables doing a special minimalistic boot to run e.g. migration scripts after installing an update (using a package manager or an image based updater like e.g. RAUC) and before the first boot of the updated system. To prevent conflicts between normal services on the system and migration scripts, normal services should not be started for these special boots. For this to work normal services may not use `WantedBy=default.target`, because according to the documentation[2] the `system-update.target` _becomes_ the `default.target` for system-update boots: 3) Very early in the new boot systemd-system-update-generator(8) checks whether /system-update or /etc/system-update exists. If so, it (temporarily and for this boot only) redirects (i.e. symlinks) default.target to system-update.target, a special target that pulls in the base system (i.e. sysinit.target, so that all file systems are mounted but little else) and the system update units. Use `WantedBy=multi-user.target` target instead of `default.target` to enable the use of `system-update.target`. [1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#default.target [2]: https://www.freedesktop.org/software/systemd/man/latest/systemd.offline-updates.html# Signed-off-by: Leonard Göhrs <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hnez The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM however podman generate systemd
still generates files with default.target, that command is deprecated but may still be worth to fix the generator?
For the replacement quadlet, user are responsible to set the WantedBy line so it is not a problem there. However the docs use default.target so they should be updated as well.https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#enabling-unit-files
... instead of default.target. According to the systemd manual[1] "typical" units should not use `WantedBy=default.target`: > For typical unit files please set "WantedBy=" to a regular target > (like multi-user.target or graphical.target), > instead of default.target, since such a service will also be run on > special boots like on system update, emergency boot… Suggest using `multi-user.target` instead. Signed-off-by: Leonard Göhrs <[email protected]>
…target ... instead of default.target. According to the systemd manual[1] "typical" units should not use `WantedBy=default.target`: > For typical unit files please set "WantedBy=" to a regular target > (like multi-user.target or graphical.target), > instead of default.target, since such a service will also be run on > special boots like on system update, emergency boot… Use `multi-user.target` instead. [1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#default.target Signed-off-by: Leonard Göhrs <[email protected]>
... instead of default.target. According to the systemd manual[1] "typical" units should not use `WantedBy=default.target`: > For typical unit files please set "WantedBy=" to a regular target > (like multi-user.target or graphical.target), > instead of default.target, since such a service will also be run on > special boots like on system update, emergency boot… Use `multi-user.target` instead. [1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#default.target Signed-off-by: Leonard Göhrs <[email protected]> Signed-off-by: Leonard Göhrs <[email protected]>
Hi @Luap99, thanks for the quick feedback! I am not too familiar with the podman codebase or even podman from a users point of view, so I am more or less Feel free to point out any mistakes I made along the way or things that are still missing. |
Yeah I think some more investigation is needed, looking at the history I found 9a10e21 So it seems simple replace is incorrect and will break all rootless users
|
Neither
So there is a real default.target unit for the user session and not just a symlink to another unit as described in the docs. As such I think the systemd docs are misleading as they only consider the root case. We assume that we can use the same unit files for root and rootless, if have to do different things in both cases that will complicate things massively. We do not have a good way to do that as of today, I hacked up a work around for another similar problem recently 6b8e8cb |
The systemd documentation says the following about using
default.target
asWantedBy=
in service files:The mentioned "system update" special boots refer to
systemd.offline-updates
a mechanism that enables doing a special minimalistic boot to run e.g. migration scripts after installing an update (using a package manager or an image based updater like e.g. RAUC) and before the first boot of the updated system.To prevent conflicts between normal services on the system and migration scripts, normal services should not be started for these special boots.
For this to work normal services may not use
WantedBy=default.target
, because according to the documentation thesystem-update.target
becomes thedefault.target
for system-update boots:Use
WantedBy=multi-user.target
target instead ofdefault.target
to enable the use ofsystem-update.target
.Does this PR introduce a user-facing change?