Bug 1282115 - rpm %transfiletriggerun is called twice per transaction
rpm %transfiletriggerun is called twice per transaction
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-14 18:59 EST by Zbigniew Jędrzejewski-Szmek
Modified: 2015-11-23 13:12 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-23 11:16:14 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Zbigniew Jędrzejewski-Szmek 2015-11-14 18:59:50 EST
Description of problem:
I'm working on using rpm file triggers in systemd. It is likely that I misunderstood something, but based on the documentation the trigger should be called just once. I added the following to systemd.spec:

%transfiletriggerun -- /usr/lib/systemd/system /etc/systemd/system
logger requesting reload "$*"
xargs logger
systemctl daemon-reload &>/dev/null || :
logger reload done

After I reinstall a package (e.g. dnf reinstall iputils) that has a systemd unit, the trigger is called twice:

Nov 14 18:45:29 fedora-rawhide zbyszek[14446]: requesting reload 0 0
Nov 14 18:45:29 fedora-rawhide zbyszek[14448]: /usr/lib/systemd/system/rdisc.service
Nov 14 18:45:29 fedora-rawhide systemd[1]: Reloading.
Nov 14 18:45:29 fedora-rawhide zbyszek[14461]: reload done
Nov 14 18:45:30 fedora-rawhide zbyszek[14463]: requesting reload 0 0
Nov 14 18:45:30 fedora-rawhide zbyszek[14465]: /usr/lib/systemd/system/rdisc.service
Nov 14 18:45:30 fedora-rawhide systemd[1]: Reloading.
Nov 14 18:45:30 fedora-rawhide zbyszek[14478]: reload done

Version-Release number of selected component (if applicable):
rpm-4.13.0-0.rc1.12.fc24.x86_64

How reproducible:
100%

Actual results:
transfiletriggerun script is called twice in the same transaction

Expected results:
transfiletriggerun script is called once per transaction.
Comment 1 Ľuboš Kardoš 2015-11-20 07:17:18 EST
I wasn't able to reproduce this. Are you sure you don't have also defined %transfiletriggerin in spec? Isn't the second log record from %transfiletriggerin instead of %transfiletriggerun?

BTW: Are you sure you really want %transfiletriggerun and not %transfiletriggerpostun?
Comment 2 Zbigniew Jędrzejewski-Szmek 2015-11-20 15:40:40 EST
I created a test package which calls /bin/logger in all scripts, to be able to debug what scripts are called: http://in.waw.pl/git/transfiletriggers/.

It confirms that %transfiletriggerun is called twice.

Also %transfiletriggerpostun is never called. Unless there's some typo that I don't see, it looks like another bug.

Initial installation of file with triggers: dnf install -y x86_64/transfiletriggers-0-1.fc24.x86_64.rpm

transfiletriggers pretrans 1                                               
transfiletriggers pre 1
transfiletriggers filetriggerin 0 0: /usr/share/doc/transfiletriggers /usr/share/doc/transfiletriggers/README
transfiletriggers filetriggerin 0 0: /usr/share/doc/setup /usr/share/doc/setup/COPYING /usr/share/doc/setup/uidgid /usr/share/doc/setup /usr/share/doc/setup/COPYING /usr/share/doc/setup/uidgid /usr/share/doc/expat /usr/share/doc/expat/README /usr/share/doc/expat /usr/share/doc/expat/README
transfiletriggers post 1
transfiletriggers posttrans 1
transfiletriggers transfiletriggerin 0 0: /usr/share/doc/setup /usr/share/doc/setup/COPYING /usr/share/doc/setup/uidgid /usr/share/doc/setup /usr/share/doc/setup/COPYING /usr/share/doc/setup/uidgid /usr/share/doc/expat /usr/share/doc/expat/README /usr/share/doc/expat /usr/share/doc/expat/README

Installation of package with triggering files: dnf install -y x86_64/transfiletriggers-a-0-1.fc24.x86_64.rpm

transfiletriggers-a pretrans 1
transfiletriggers-a pre 1
transfiletriggers filetriggerin 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a post 1
transfiletriggers-a posttrans 1
transfiletriggers transfiletriggerin 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README

Reinstallation: dnf reinstall -y x86_64/transfiletriggers-a-0-1.fc24.x86_64.rpm

transfiletriggers transfiletriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers transfiletriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a pretrans 2
transfiletriggers-a pre 2
transfiletriggers filetriggerin 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a post 2
transfiletriggers filetriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a preun 1
transfiletriggers filetriggerpostun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a postun 1
transfiletriggers-a posttrans 1
transfiletriggers transfiletriggerin 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README

Removal: dnf remove -y transfiletriggers-a

transfiletriggers transfiletriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers transfiletriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers filetriggerun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a preun 0
transfiletriggers filetriggerpostun 0 0: /usr/share/doc/transfiletriggers-a /usr/share/doc/transfiletriggers-a/README
transfiletriggers-a postun 0

> BTW: Are you sure you really want %transfiletriggerun and not %transfiletriggerpostun?

I need to call 'systemctl daemon-reload' with the following constraints:
1. After files have been added/removed/upgraded.
2. Before restarting daemons which were upgraded.

Ideally, we would run 'systemctl daemon-reload' just once, but if that's not possible, we can live with multiple calls as long as we get at least one call satisfying 1. and at least one call satisfying 2.

Restarting daemons which were upgraded is currently done through %postun scriptlets in individual packages. This means that we would like 2. to be implemented as "before %postun scriptlets in packages".

Looking at the debug logs above, this isn't currently possible (without saving state on disk or something like that). Any help would be appreciated.
Comment 3 Ľuboš Kardoš 2015-11-23 11:16:14 EST
Now, I see where the problem is. It is reproducible only when reinstall is performed by dnf, if "rpm --reinstall" is used then it works. Both calling %transfiletriggerun twice per transaction and not calling %transfiletriggerpostun at all should be fixed in rpm-4.13.0-0.rc1.13.fc24.

Because the bug is fixed I am closing it. If you have still problem how to use file triggers with the fixed rpm version then contact me by email or send email to rpm-list@lists.rpm.org.
Comment 4 Zbigniew Jędrzejewski-Szmek 2015-11-23 13:05:00 EST
Thanks for the quick fix. I can confirm that I don't see %transfiletriggerun called twice.

Unfortunately %transfiletriggerpostun is still not called. I'll open a separate bug.

Note You need to log in before you can comment on or make changes to this bug.