From 718b06c86618e5240e6a73ec67aab5cef9db6678 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 18 Jun 2026 06:52:39 +0200 Subject: [PATCH] tests: ignore masked units in check-and-shutdown 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 | 6 +++++- mkosi.postinst | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh b/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh index 108e686fe..bddb53ac4 100755 --- a/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh +++ b/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh @@ -2,7 +2,11 @@ # 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 ]] diff --git a/mkosi.postinst b/mkosi.postinst index 390f34ae9..dd7b74681 100755 --- a/mkosi.postinst +++ b/mkosi.postinst @@ -2,4 +2,7 @@ # 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 -- 2.47.3