Subject: Re: bug#76338: shepherd restarts service during shutdown and then waits forever

From: Ludovic Courtès <[email-masked]>
Date: Fri, 21 Feb 2025 11:52:01 +0100

Hello,

Dariqq <[email-masked]> skribis:

> The two services that I know of are thermald and virtlogd.

I found these:

--8<---------------cut here---------------start------------->8---
scheme@(guix scripts system search)> ,pp (map shepherd-service-provision
					      (append-map (lambda (services)
							    (remove (lambda (service)
								      (memq 'user-processes
									    (shepherd-service-requirement service)))
								    services))
							  (map service-type-default-shepherd-services (fold-service-types cons '()))))
$7 = ((user-homes)
      (tailon)
      (agate)
      (varnish-default)
      (httpd)
      (fcgiwrap)
      (mumi)
      (mumi-worker)
      (mumi-mailer)
      (php-fpm)
      (whoogle-search)
      (hpcguix-web)
      (gmnisrv)
      (vpn-client)
      (ipsec)
      (vpn-server)
      (xvnc vncserver)
      (git-daemon)
      (mumble-server)
      (jami-dbus-session)
      (jami)
      (sysctl)
      (autossh)
      (ssh-daemon ssh sshd)
      (webssh)
      (ssh-daemon ssh sshd)
      (ssh-daemon ssh sshd)
      (spice-vdagentd)
      (speakersafetyd)
      (system-log syslogd)
      (pcscd)
      (samba-nmbd)
      (samba-smbd)
      (samba-winbindd)
      (wsdd)
      (rsync)
      (thermald)
      (rpcbind-daemon)
      (idmap-daemon)
      (gss-daemon)
      (rpc-pipefs)
      (pagekite)
      (ipfs)
      (vswitchd)
      (unblocked-wifi)
      (iptables)
      (nftables)
      (opendht dhtnode dhtproxy)
      (prometheus-node-exporter)
      (vnstatd)
      (radicale)
      (dovecot)
      (rspamd)
      (imap4d)
      (kernel-module-loader)
      (rasdaemon)
      (cachefilesd)
      (directory-server-localhost)
      (guix-data-service)
      (guix-data-service-setup-database)
      (guix-data-service-process-jobs)
      (guix-build-coordinator)
      (wesnoth-daemon)
      (joycond)
      (transmission-daemon transmission bittorrent)
      (dockerd)
      (containerd)
      (kresd)
      (dnsmasq)
      (inputattach)
      (elogind)
      (bluetooth)
      (x11-socket-directory)
      (seatd elogind)
      (upower-daemon)
      (postgres-roles)
      (mysql-upgrade)
      (cups)
      (cgroups2-limits)
      (cgroups2-fs-owner)
      (laminar)
      (gpm)
      (udev)
      (urandom-seed)
      (virtual-terminal)
      (trng)
      (user-processes)
      (auditd))
--8<---------------cut here---------------end--------------->8---

Some of them are legitimate, many are not.  (Not sure why ‘virtlogd’
doesn’t show up here.)

> Also the purpose of the user-processes service (and maybe also the
> filesystems) service as synchronization targets are documented only in
> their definition and implicitly with the shepherd graph
> image. System-shepherd services that dont depend on anything are
> probably a bad idea and seems like a very common mistake for (new)
> users implementing their own services.
> Maybe this should be a a more explicit note in the documentation for
> shepherd-service-requirement and/or a small paragraph in the shepherd
> services intro?

Yes, agreed.  I’m not entirely sure where to document it; do you have
ideas?

(The doc in this area probably needs a Spring cleanup…)

> Is there a reason for user-processes to block on waiting for every
> process execpt PID1 to exit or why during the (sleep 1) calls other
> services (that falsely dont depend on user-processes) are not being
> stopped in the meantime which would help resolve the deadlock?

The assumption is that services have been stopped by the time
‘user-processes’ is stopped (because they’re supposed to depend on it).
Thus, when ‘user-processes’ is stopped, normally only user processes are
left.

> But insisting on restarting a service seems a bit pointless to me
> during shutdown/reboot where everything will be terminated anyway.

Agreed, I’ll see how to do that on the shepherd side.

Thanks,
Ludo’.