]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
tests: ignore masked units in check-and-shutdown main
authorMartin Pitt <martin@amutable.com>
Thu, 18 Jun 2026 04:52:39 +0000 (06:52 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Fri, 19 Jun 2026 13:22:56 +0000 (15:22 +0200)
Masking lvm2-monitor.service in 899dfbd45 did not actually stop it from
tripping the boot check: a masked unit that udev pulls in when scanning a
disk image's partitions still fails to start and is listed by
`systemctl --failed` with ACTIVE=failed. Masking only changed the LOAD
column from `not-found` to `masked`.

A masked unit failing to start is noise, not a real service failure in the
image, so filter masked units out of the failed-services check.

Also explain mkosi.postinst *why* lvm2-monitor.service even fails in the
first place: It's only installed in the initrd, not the main image. That
may or may not be a bug, but it's uninteresting for the "failed
services?" check.

mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh
mkosi.postinst

index 108e686fe0e4f0335f89b48ae497f13940e8d87a..bddb53ac431f2559316431bb07254e5d91056eb1 100755 (executable)
@@ -2,7 +2,11 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -eux
 
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -eux
 
-systemctl --failed --no-legend | tee /failed-services
+# Ignore masked units (in particular lvm2-monitor.service,, see mkosi.postinst); these
+# are not a real image failure
+systemctl --failed --no-legend --plain |
+    awk '$2 != "masked"' |
+    tee /failed-services
 
 # Exit with non-zero EC if the /failed-services file is not empty (we have -e set)
 [[ ! -s /failed-services ]]
 
 # Exit with non-zero EC if the /failed-services file is not empty (we have -e set)
 [[ ! -s /failed-services ]]
index 390f34ae9e0030233c19f0d723e7afcd7b05829b..dd7b746818a078f00e7bbd8c7ff5b95543d58460 100755 (executable)
@@ -2,4 +2,7 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
 # SPDX-License-Identifier: LGPL-2.1-or-later
 set -ex
 
+# Enabled in the initrd (which has lvm2) and can fail there when udev activation races dmeventd.
+# That failed state is inherited across switch-root into the main image, where lvm2 isn't even
+# installed, surfacing as not-found/failed noise. Mask it so mkosi-check-and-shutdown.sh ignores it.
 systemctl --root="$BUILDROOT" mask lvm2-monitor.service
 systemctl --root="$BUILDROOT" mask lvm2-monitor.service