[systemd-devel] Starting a socket unit that finds an active service fails

Lennart Poettering lennart at poettering.net
Fri Jan 29 15:38:59 UTC 2021


On Fr, 29.01.21 12:30, Ulrich Windl (Ulrich.Windl at rz.uni-regensburg.de) wrote:

> Hi!
>
> I wonder whether this is a bug:
> When starting a socket unit that finds ist service active already, I get an error
> systemd[1]: libvirtd-tls.socket: Socket service libvirtd.service already active, refusing.
> systemd[1]: Failed to listen on Libvirt TLS IP socket.
>
> When using systemd units in a pacemaker cluster this is fatal:
> pacemaker-controld[7467]:  notice: Transition 316 action 81 (prm_libvirtd-tls-sock_start_0 on rksaph19): expected 'ok' but got 'error'
>
> Maybe the special problem is that two socket units (libvirtd-ro.socket, libvirtd-tls.socket) exist to start the same service (libvirtd.service).
>
> I'm clueless how to handle that. Ideas?

The socket activation logic works so that the activation sockets are
passed to the service being activated during execve(). Thus, if a
service is already running we can't pass in more sockets: you have to
restart the service so that there's another execve() we can pass the
newly started sockets over.

My guess is that your service — if it finds that it didn't get a
socket passed in that it needs — just creates the socket itself as a
fallback...

It's generally a good idea for services to have Requires= + After= on
the sockets that actviate it, to make sure that the sockets are always
started before the service itself, and the situation you are seeing
cannot happen.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list