[v3,1/1] image-postproc: ignore systemd preset failures

Message ID 20260219044406.441933-2-badrikesh.prusty@siemens.com
State New
Headers show
Series [v3,1/1] image-postproc: ignore systemd preset failures | expand

Commit Message

Prusty, Badrikesh Feb. 19, 2026, 4:44 a.m. UTC
Add '|| true' to systemd preset invocation during image postprocessing
to tolerate failures caused by already-masked units.

Signed-off-by: Badrikesh Prusty <badrikesh.prusty@siemens.com>
---
 meta/classes-recipe/rootfs.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

MOESSBAUER, Felix Feb. 19, 2026, 1:36 p.m. UTC | #1
On Wed, 2026-02-18 at 23:44 -0500, 'Badrikesh Prusty' via isar-users
wrote:
> Add '|| true' to systemd preset invocation during image postprocessing
> to tolerate failures caused by already-masked units.
> 
> Signed-off-by: Badrikesh Prusty <badrikesh.prusty@siemens.com>
> ---
>  meta/classes-recipe/rootfs.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/rootfs.bbclass b/meta/classes-recipe/rootfs.bbclass
> index 8485b32f..ef3ddb84 100644
> --- a/meta/classes-recipe/rootfs.bbclass
> +++ b/meta/classes-recipe/rootfs.bbclass
> @@ -574,7 +574,7 @@ image_postprocess_populate_systemd_preset() {
>          --show systemd || echo "" )
>  
>      if (test "$SYSTEMD_INSTALLED" = "installed"); then
> -        sudo chroot '${ROOTFSDIR}' systemctl preset-all --preset-mode="enable-only"
> +        sudo chroot '${ROOTFSDIR}' systemctl preset-all --preset-mode="enable-only" || true

This is still too coarse. Currently the presetting fails on bullseye
targets with the following error "Failed to preset: Invalid argument.".

While I did not check the root-cause, I'm pretty sure this is a
different error which would be hidden by || true.

Felix
Prusty, Badrikesh Feb. 19, 2026, 3:26 p.m. UTC | #2
Hi,

I guess the error of invalid argument is due to invalid preset configs
in /usr/lib/systemd/system-preset/ or the preset files missing in
system-preset/ directory. With my initial check the `preset-all` and
`preset-mode` flags are available since systemd v215.

For masked service failures, I tested this on my systems locally with a
newer version of systemd as well. The command also fails with exit code
1 when running the preset on Debian Trixie and Forky. I’m not sure how
the builds for Trixie continues despite these failures.

Logs:
```
> systemctl --version
systemd 259 (259-1)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +IPE +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF -XKBCOMMON -UTMP +SYSVINIT +LIBARCHIVE
547G ~
> sudo systemctl preset-all --preset-mode="enable-only"
Failed to preset all units: Unit /etc/systemd/system/hibernate.target is masked
547G ~
> echo $?
1

> systemctl --version
systemd 257 (257.9-1~deb13u1)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +IPE +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF -XKBCOMMON -UTMP +SYSVINIT +LIBARCHIVE
847E ~
> sudo systemctl preset-all --preset-mode="enable-only"
Failed to preset all units: Unit /etc/systemd/system/sleep.target is masked
847E ~
> echo $?
1
```

Patch

diff --git a/meta/classes-recipe/rootfs.bbclass b/meta/classes-recipe/rootfs.bbclass
index 8485b32f..ef3ddb84 100644
--- a/meta/classes-recipe/rootfs.bbclass
+++ b/meta/classes-recipe/rootfs.bbclass
@@ -574,7 +574,7 @@  image_postprocess_populate_systemd_preset() {
         --show systemd || echo "" )
 
     if (test "$SYSTEMD_INSTALLED" = "installed"); then
-        sudo chroot '${ROOTFSDIR}' systemctl preset-all --preset-mode="enable-only"
+        sudo chroot '${ROOTFSDIR}' systemctl preset-all --preset-mode="enable-only" || true
     fi
 }