#2164 backend: automatically restart services in %post
Merged 3 months ago by praiskup. Opened 4 months ago by frostyx.
copr/ frostyx/copr restart-copr-be  into  main

file modified
+3 -1
@@ -200,7 +200,9 @@ 

  %systemd_preun copr-backend.target

  

  %postun

- %systemd_postun_with_restart copr-backend.target

+ %systemd_postun_with_restart copr-backend-log.service

+ %systemd_postun_with_restart copr-backend-build.service

+ %systemd_postun_with_restart copr-backend-action.service

  

  %files

  %license LICENSE

Build succeeded.

Hm, I'm curious why %systemd_postun_with_restart copr-backend.target doesn't work the way we need? Is that because we use *.target?

I believe that the restart is done by %postun
Here is the relevant part of documentation https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_scriptlets

And the postun expands to:

$ rpm --eval '%systemd_postun_with_restart foo'


if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then 
    # Package upgrade, not uninstall 
    /usr/lib/systemd/systemd-update-helper mark-restart-system-units foo || : 
fi

That's what I've seen too, but for some reason the set of services in the copr-backend.target really isn't restarted. I'm curious if this is a bug in the macro, systemd, or we misuse it.

rebased onto 91bf03f

3 months ago

Build succeeded.

I asked on #fedora-devel about restarting a target and the response
was "What would restarting target even mean?". I also didn't find any
mentions of restarting targets in the documentation.

The man systemd.target doesn't go into detail about the possible
use-cases of targets, it only mentions "grouping units and as
well-known synchronization points during start-up."

ArchWiki even equates targets to SysV runlevels,
https://wiki.archlinux.org/title/systemd#Targets
so in this context, restarting targets doesn't make sense as well.

I don't know if our copr-backend.target is a valid use-case but it
IMHO doesn't matter. We can file a RFE for supporting targets in
%systemd_postun_with_restart but for the time being, I would just
change our specfile and list all services that should be restarted.

FTR, I also asked on #systemd and no answer so far.

Commit f55c883 fixes this pull-request

Pull-Request has been merged by praiskup

3 months ago
Metadata