From 149e3ead96ba3b835acbca5b3682c98a6da209a6 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 21 Aug 2024 15:04:38 +0200 Subject: [PATCH] util/chroot: call unmount with check=False If one of the chroot mounts fails to unmount, keep iterating so that we don't stop and continue to unmount the rest. Print an error message with the failed mounts, but don't fail the build. Since failing to unmount doesn't fail the exiting of the context, and the context itself doesn't know what will be running in the chroot, do a lazy unmount. --- osbuild/util/chroot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osbuild/util/chroot.py b/osbuild/util/chroot.py index 661a7a8f..5bc1d873 100644 --- a/osbuild/util/chroot.py +++ b/osbuild/util/chroot.py @@ -37,5 +37,9 @@ class ChrootProcDevSys: return self def __exit__(self, exc_type, exc_value, tracebk): + failed_umounts = [] for d in ["/proc", "/dev", "/sys"]: - subprocess.check_call(["/usr/bin/umount", self.root + d]) + if subprocess.run(["/usr/bin/umount", "--lazy", self.root + d], check=False).returncode != 0: + failed_umounts.append(d) + if failed_umounts: + print(f"Error unmounting paths from chroot: {failed_umounts}")