[Bug 1112991] New: syatemd-rpm-macros: missing method for reload instead of restart on update
http://bugzilla.suse.com/show_bug.cgi?id=1112991 Bug ID: 1112991 Summary: syatemd-rpm-macros: missing method for reload instead of restart on update Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem Assignee: bnc-team-screening@forge.provo.novell.com Reporter: ro@suse.com QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- see also home:oertel:branches:Base:System/systemd-rpm-macros +Wed Oct 24 01:08:16 CEST 2018 - ro@suse.de + +- add -r option for service_del_postun to allow + for reload instead of restart on update --- macros.systemd (revision 1) +++ macros.systemd (working copy) @@ -63,6 +63,14 @@ "$DISABLE_RESTART_ON_UPDATE" = 1 && exit 0\ %{?*:/usr/bin/systemctl try-restart %{*}}\ ) || : %{nil} +%_restart_on_update_reload() (\ + test "$YAST_IS_RUNNING" = instsys && exit 0\ + test -f /etc/sysconfig/services -a \\\ + -z "$DISABLE_RESTART_ON_UPDATE" && . /etc/sysconfig/services\ + test "$DISABLE_RESTART_ON_UPDATE" = yes -o \\\ + "$DISABLE_RESTART_ON_UPDATE" = 1 && exit 0\ + %{?*:/usr/bin/systemctl try-reload-or-restart %{*}}\ + ) || : %{nil} %_stop_on_removal_force() ( \ test "$YAST_IS_RUNNING" = instsys && exit 0\ @@ -173,13 +181,13 @@ # variable if not found use the value read from /etc/sysconfig/services # -%service_del_postun(fn) \ +%service_del_postun(fnr) \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ if [ "$FIRST_ARG" -ge 1 ]; then \ # Package upgrade, not uninstall \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload || : \ - %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ + %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}}%{!-f:%{!-n:%{-r:_reload}}} %{?*}} \ fi \ else # package uninstall \ for service in %{?*} ; do \ -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
Zejin Xu
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c1
Franck Bui
see also home:oertel:branches:Base:System/systemd-rpm-macros
Could you describe the problem you're trying to solve ? Why would you want to avoid restarting a service on a package update ? -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
Franck Bui
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c2
Ruediger Oertel
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c3
--- Comment #3 from Franck Bui
it's basically the old "ExecRestart" discussion.
Any links to share ?
Some services want to implement the Restart action themselves, in this case because they want to pass on file descriptors to their successor.
What do you mean by "themselves" ? PID1 offers an API to services/daemons for sending and storing their fds for this case. See logind and journald for examples. Do you mean that in your case this API can't be used ? if so can you explain why ? -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c4
Ruediger Oertel
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c5
Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c6
--- Comment #6 from Franck Bui
As Rudi said: we wan't a graceful restart with no downtime at all.
Well that's what most other services want to implement so this is not new and as I said journald, logind... already implement that.
Regarding #3: what interface?
Please read https://www.freedesktop.org/software/systemd/man/sd_notify.html -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c7
--- Comment #7 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c8
--- Comment #8 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c9
--- Comment #9 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c10
--- Comment #10 from Franck Bui
And how would this work from a perl program?
The daemon is implemented in perl ? that's not really common... (In reply to Michael Schröder from comment #8)
Also note that this is *way* more complicated than it needs to be.
Well, how do you plan to implement that exactly otherwise ? (In reply to Michael Schröder from comment #9)
(It's also not clear to me that stopping the service will make systemd close all stored fds. Is that the case?)
Sure. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c11
--- Comment #11 from Michael Schröder
The daemon is implemented in perl ? that's not really common...
Now that's a helpful comment...
Well, how do you plan to implement that exactly otherwise ?
Exactly what Rudi proposed.
Sure.
(I couldn't find that in the systemd code, that's why I was asking.) -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c12
--- Comment #12 from Franck Bui
Well, how do you plan to implement that exactly otherwise ?
Exactly what Rudi proposed.
That's not clear. My current understanding of your needs is that you want a new (hackish) option (BTW the existing options are already hacks) because your service don't support "true" restarting. So instead you just ask your daemon to reload its configuration during package update while the daemon is supposed to be re-executed so the new binary is in-use. If so I would suggest to either implement a proper way to send the fds to systemd or to implement your own logic in your package. So if I'm getting this right, creating new macros or adding new options for encouraging this odd case is not an option, sorry. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c13
--- Comment #13 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c14
--- Comment #14 from Franck Bui
Your suggestions are not really helping. Please show me how to do that filedescriptor sending/receiving in perl.
A perl module wrapping parts of libsystemd would be needed I guess like python-systemd does for python. But I guess you already looked for search module. BTW which package are talking about ? -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c17
--- Comment #17 from Franck Bui
Anyway, here's some more information from me:
Thanks, please next time include such description earlier.
The package we're talking about is the OBS backend server, serving requests on a socket. Our goal is to do a graceful restart on package update. This means:
1) we do not want to close the server socket 2) we want the current jobs to finish (this might take a couple of minutes for some types, the server has special code to deal with longrunning jobs)
So we can't use systemd's restart mechanism which does a hard start/stop.
Well as discussed previously, you're supposed to use sd_notify() in this case. But it appears that no perl bindings exists currently so they should implemented like python-systemd does for python.
Instead, we opted to 'hijack' the reload mechanism. (A graceful restart is also the only way to reload the server config, so it's not that far-fetched.)
We do this since quite some time with sysv-init style scripts, but now we want to migrate to systemd service files. That's why Rudi is asking for some way to make the package update to a reload instead of a restart.
I understand that the current proposed change is somewhat invasive for this special case, but maybe we can do something simpler: How about adding
The problem is not about how invasive the changes would be but making a somehow 'special' case officially available. Again the official way for a service to preserve its file-descriptors is to send them to PID1. IMHO until such API becomes available for perl, you should just call 'try-reload-or-restart' command in the %postun section of your package. Hope that makes sense. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c18
--- Comment #18 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c19
--- Comment #19 from Franck Bui
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c20
--- Comment #20 from Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c21
--- Comment #21 from Franck Bui
The point is that we do not want a "restart on update" in the systemd sense. We want something more graceful on package update.
The problem here is that different packages will need different custom actions. For example one will need to be re-executed with a command of its own (such as fooctl reexecute) another one might want to receive a signal, in your case you want to reload and so on.. I don't see how all of these different cases could be hidden via a rpm macro and the point of doing it actually. The rpm macros have been created to deal with the generic cases only where stop/start is enough. If you need to do more involved stuff, then it's better to write the commands explicitely instead of trying to hide them behind macros. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c22
Michael Schröder
http://bugzilla.suse.com/show_bug.cgi?id=1112991
http://bugzilla.suse.com/show_bug.cgi?id=1112991#c23
--- Comment #23 from Franck Bui
participants (1)
-
bugzilla_noreply@novell.com