<div dir="ltr"><div class="gmail_default" style="font-size:small"></div><div class="gmail_quote"><div dir="ltr"><div style="font-size:small">Hi,</div><div style="font-size:small"><br></div><div style="font-size:small"><div style="font-size:small" class="gmail_default">tl;dr</div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">I filed <a href="https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1928259">https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1928259</a> found while testing <a href="https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1927745">https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1927745</a> and verifying that rpc.gssd was not restarted after a package upgrade. Which means the fix wasn't available until the service was restarted manually.<br></div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default"># Troubleshooting story<br></div></div><div style="font-size:small"><br></div><div style="font-size:small">I<span class="gmail_default" style="font-size:small"> was</span> testing <a href="https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1927745" target="_blank">https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1927745</a>, and while the fix is correct, it didn't always "stick" after I upgraded the packages.</div><div style="font-size:small"><br></div><div style="font-size:small">Further troubleshooting showed that some of the NFS services are not restarted after a package upgrade, under a specific condition which took a while to figure out.</div><div style="font-size:small"><br></div><div style="font-size:small">Many services make up a NFS server or client, so sometime ago debian decided to wrap them all around a systemd service called nfs-utils.service, which is a bit fake, used just to coordinate all the real services. Its header explains it:<br></div><div style="font-size:small">$ systemctl cat nfs-utils.service<br># /lib/systemd/system/nfs-utils.service<br>[Unit]<br>Description=NFS server and client services<br># This service should never be stopped, only restarted.<br># When it is re-started, all other services which declare<br># themselves to be "PartOf" this service will also be<br># restarted. Thus<br># systemctl restart nfs-utils<br># will restart all daemons which are part of nfs-utils<br># and which are running. This is useful after a software<br># update.<br><br># This is a "service" rather than "target" so that we<br># don't need to say "systemctl restart nfs-utils.target".<br>[Service]<br>Type=oneshot<br>RemainAfterExit=yes<br>ExecStart=/bin/true</div><div style="font-size:small"><br></div><div style="font-size:small">d/rules has these, and we can see it does not enable nfs-utils.service, but asks for it to be restarted on upgrade:<br></div><div style="font-size:small"> dh_systemd_enable -p nfs-common nfs-client.target <br> dh_systemd_enable -p nfs-kernel-server nfs-server.service <br> dh_installinit -pnfs-common -R <br> dh_systemd_start -p nfs-common --restart-after-upgrade nfs-utils.service <br> dh_systemd_start -p nfs-kernel-server --restart-after-upgrade nfs-server.service<br></div><div style="font-size:small"><br></div><div style="font-size:small">And this "fake" service really can't be enabled:</div><div style="font-size:small">$ sudo systemctl enable nfs-utils.service<br>The unit files have no installation config (WantedBy, RequiredBy, Also, Alias<br>settings in the [Install] section, and DefaultInstance for template units).</div><div style="font-size:small">(...long explanation follows this output ...)</div><div style="font-size:small"><br></div><div style="font-size:small">We get this during package install:</div><div style="font-size:small">Setting up nfs-common (1:1.3.4-2.1ubuntu5.3) ...<br>nfs-utils.service is a disabled or a static unit not running, not starting it.</div><div style="font-size:small"><br></div><div style="font-size:small">Even when upgrading:</div><div style="font-size:small">Setting up nfs-common (1:1.3.4-2.1ubuntu5.4) ...<br>nfs-utils.service is a disabled or a static unit not running, not starting it.</div><div style="font-size:small"><br></div><div style="font-size:small">This is because the service is not enabled.</div><div style="font-size:small"><br></div><div style="font-size:small">Critically for the bug I'm fixing, rpc.gssd is not restarted, so the fix isn't applied :/</div><div style="font-size:small">Before upgrade:</div><div style="font-size:small"> 442 ? Ss 0:00 /usr/sbin/blkmapd<br> 7146 ? Ss 0:00 /usr/sbin/rpc.gssd<br> 7399 ? Ss 0:00 /usr/sbin/rpc.idmapd<br> 7406 ? Ss 0:00 /usr/sbin/rpc.mountd --manage-gids<br> 7400 ? Ss 0:00 /usr/sbin/rpc.svcgssd</div><div style="font-size:small">After pkg upgrade:</div><div style="font-size:small"> 442 ? Ss 0:00 /usr/sbin/blkmapd<br> 7146 ? Ss 0:00 /usr/sbin/rpc.gssd<br> 8421 ? Ss 0:00 /usr/sbin/rpc.idmapd<br> 8422 ? Ss 0:00 /usr/sbin/rpc.mountd --manage-gids<br> 8420 ? Ss 0:00 /usr/sbin/rpc.svcgssd<br></div><div><br></div><div><div style="font-size:small">If I do a manual "sudo systemctl start nfs-utils.service" (or restart) before upgrading the package, then all these processes are restarted after the package upgrade<span class="gmail_default" style="font-size:small">, because deb-systemd-invoke sees nfs-utils.service as "started". From its code:</span></div><div style="font-size:small"><span class="gmail_default" style="font-size:small"># If the job is disabled and is not currently running, the job is not started or restarted.<br># However, if the job is disabled but has been forced into the running state, we *do* stop<br># and restart it since this is expected behaviour for the admin who forced the start.<br># We don't autostart static units either.</span></div><div style="font-size:small"><br></div><div style="font-size:small"><div style="font-size:small" class="gmail_default">I filed <a href="https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1928259">https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1928259</a> and <a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988430">https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988430</a>.</div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">Some ideas I'm considering:</div><div style="font-size:small" class="gmail_default">a) just do a systemctl start before the #DEBHELPER# marker, like this:</div><div style="font-size:small" class="gmail_default">--- a/debian/nfs-common.postinst<br>+++ b/debian/nfs-common.postinst<br>@@ -43,6 +43,10 @@ case "$1" in<br> if [ -f /lib/init/rw/sendsigs.omit.d/statd ]; then <br> mv /lib/init/rw/sendsigs.omit.d/statd /run/sendsigs.omit.d/statd<br> fi<br>+<br>+ # always "start" nfs-utils.service, so package upgrades will restart it,<br>+ # see LP: #1928259<br>+ systemctl start nfs-utils.service > /dev/null || true<br> ;;<br> esac<br> <br></div><div style="font-size:small" class="gmail_default"><br></div><div style="font-size:small" class="gmail_default">b) Don't use dh_systemd_* in d/rules for nfs-utils.service, and do my own handling in d/nfs-common.postinst using systemctl directly, instead of deb-systemd-invoke, i.e., something like (also untested):</div><div style="font-size:small" class="gmail_default">diff --git a/debian/nfs-common.postinst b/debian/nfs-common.postinst<br>index f709d53..feb375a 100644<br>--- a/debian/nfs-common.postinst<br>+++ b/debian/nfs-common.postinst<br>@@ -43,11 +43,19 @@ case "$1" in<br> if [ -f /lib/init/rw/sendsigs.omit.d/statd ]; then<br> mv /lib/init/rw/sendsigs.omit.d/statd /run/sendsigs.omit.d/statd<br> fi<br>-<br>- # always "start" nfs-utils.service, so package upgrades will restart it,<br>- # see LP: #1928259<br>- systemctl start nfs-utils.service > /dev/null || true<br> ;;<br> esac<br><br>+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then<br>+ if [ -d /run/systemd/system ]; then<br>+ systemctl --system daemon-reload >/dev/null || true<br>+ if [ -n "$2" ]; then<br>+ _dh_action=restart<br>+ else<br>+ _dh_action=start<br>+ fi<br>+ systemctl $_dh_action 'nfs-utils.service' >/dev/null || true<br>+ fi<br>+fi<br>+<br> #DEBHELPER#<br>diff --git a/debian/rules b/debian/rules<br>index 8bb2f25..3259d3b 100755<br>--- a/debian/rules<br>+++ b/debian/rules<br>@@ -57,7 +57,6 @@ binary-arch: build<br> dh_systemd_enable -p nfs-common nfs-client.target<br> dh_systemd_enable -p nfs-kernel-server nfs-server.service<br> dh_installinit -pnfs-common -R<br>- dh_systemd_start -p nfs-common --restart-after-upgrade nfs-utils.service<br> dh_systemd_start -p nfs-kernel-server --restart-after-upgrade nfs-server.service<br> install -m 0755 debian/nfs-kernel-server.init debian/nfs-kernel-server/etc/init.d/nfs-kernel-server<br> install -m 0644 debian/nfs-common.bugcontrol debian/nfs-common/usr/share/bug/nfs-common/control</div></div><div style="font-size:small"><br></div><div style="font-size:small"><div style="font-size:small" class="gmail_default">I just grabbed the bits that debhelper added for the dh_systemd_start line I removed, and replaced deb-systemd-invoke with systemctl<br></div><br></div><div style="font-size:small"><br></div><div style="font-size:small"><br></div><div style="font-size:small">Any<span class="gmail_default" style="font-size:small"> other</span> ideas?<br></div><br></div></div>
</div></div>