Package: debhelper
Version: 12.10
X-Debbugs-CC: a...@sigxcpu.org

Hi,
I've seen this  in package libvirt in Ubuntu as well as Debian, but it
might be more widespread without me being aware of it. If we install
the package all is fine, but on a --reinstall or upgrade it will show
warnings about services like:

Setting up libvirt-daemon-system (6.0.0-0ubuntu6) ...
Job failed. See "journalctl -xe" for details.

It comes down to:
  systemd[1]: libvirtd-ro.socket: Socket service libvirtd.service
already active, refusing.
but I was tracking that down for [1] and it is more complex than just that.
I found the ordering of sockets mentioned as "Also" to be the reason,
let me outline the details ...

libvirtd.service has a few related sockets.
$ grep Also /lib/systemd/system/libvirtd.service
Also=virtlockd.socket
Also=virtlogd.socket
Also=libvirtd.socket
Also=libvirtd-ro.socket

Due to that the following entry in d/rules:
  dh_installsystemd -p libvirt-daemon-system --restart-after-upgrade
libvirtd.service

Gets generated into postinst automatically pulling in all the "Also" statements.
But also ordering them alphabetically.

if [ -n "$2" ]; then
    _dh_action=restart
else
    _dh_action=start
fi
deb-systemd-invoke $_dh_action 'libvirtd-ro.socket' 'libvirtd.service'
'libvirtd.socket' 'virtlockd.socket' 'virtlogd.socket' >/dev/null ||
true

Due to that the "libvirtd-ro.socket" is restarted before the service
and fails as the service is already up. The sockets listed later work
fine.

The following order would work fine (service first, then sockets):
 $ deb-systemd-invoke restart 'libvirtd.service' 'libvirtd-ro.socket'
'libvirtd.socket' 'virtlockd.socket' 'virtlogd.socket
(but IMHO that might be racy still).

I was wondering if dh_installsystemd should maybe:
A) always order the service it was called with as first entry?
B) not pull in "ALSO" statements if they are sockets?
C) add an option to influence that behavior as needed per-package?
D) ... ?

I'm a bit lost on what the best option might be, therefore I wanted to
open this bug for a discussion.

[1]: https://bugs.launchpad.net/ubuntu/+source/debhelper/+bug/1869796


-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

Reply via email to