Systemd: RPM macros, triggers: unexpected ordering between %systemd_postun_with_restart and daemon-reload

Created on 21 Feb 2019  路  1Comment  路  Source: systemd/systemd

systemd version the issue has been seen with
239


Used distribution
CentOS 7, with facebookincubator/rpm-backports.

Expected behaviour you didn't see
Upgrading an RPM that modifies a unit file should execute systemctl daemon-reload prior to systemctl try-restart.

Unexpected behaviour you saw

# rpm -Uvv package.rpm
[... %post and %preun scriplets work as expected ...]
D: %postun(fb-kernel-iostats-20190116-221434.x86_64): scriptlet start
[...]
+ '[' 1 -ge 1 ']'
+ systemctl try-restart kernel-blklatencyd.service
D: %postun(fb-kernel-iostats-20190116-221434.x86_64): waitpid(3178593) rc 3178593 status 0
[...]
D: running post-transaction scripts
D: %triggerin(systemd-239-1.fb6.x86_64): scriptlet start
D: %triggerin(systemd-239-1.fb6.x86_64): execv(/bin/sh) pid 3178697
D: Plugin: calling hook scriptlet_fork_post in selinux plugin
+ test -d /run/systemd/system
+ /usr/bin/systemctl daemon-reload

In effect, the systemctl try-restart executes while the new binary is installed on the target system, yet the old unit file is still loaded into systemd. Only a subsequent restart after the RPM transaction triggers complete will successfully start the service.

Steps to reproduce the problem
This is also reproducible in Fedora (I arbitrarily chose rng-tools):

$ cd $(mktemp -d)
$ sudo dnf downgrade rng-tools
$ dnf download rng-tools
$ sudo rpm -Uvv rng-tools-6.3.1-2.fc29.x86_64.rpm |& grep systemctl
+ systemctl try-restart rngd.service
+ '[' -x /usr/bin/systemd-run -a -x /usr/bin/systemctl ']'
+ /usr/bin/systemd-run /usr/bin/systemctl start man-db-cache-update
+ /usr/bin/systemctl daemon-reload
+ '[' -x /usr/bin/systemd-run -a -x /usr/bin/systemctl ']'
+ /usr/bin/systemd-run /usr/bin/systemctl start man-db-cache-update
rpm

Most helpful comment

Issue remains in systemd 246 impacting CentOS7, CentOS8 and Fedora32. Per Red Hat, systemd has the script order wrong. %transfiletriggerin (where systemd does daemon-reload) runs after the entire RPM transaction including all package-specific scripts such %postun where the systemd macro attempts to do try-restart.

https://bugzilla.redhat.com/show_bug.cgi?id=1883338
https://rpm.org/user_doc/file_triggers.html

>All comments

Issue remains in systemd 246 impacting CentOS7, CentOS8 and Fedora32. Per Red Hat, systemd has the script order wrong. %transfiletriggerin (where systemd does daemon-reload) runs after the entire RPM transaction including all package-specific scripts such %postun where the systemd macro attempts to do try-restart.

https://bugzilla.redhat.com/show_bug.cgi?id=1883338
https://rpm.org/user_doc/file_triggers.html

Was this page helpful?
0 / 5 - 0 ratings