cros_sdk_lib: extra logging for CleanupChrootMount
Add extra logging in CleanupChrootMount when UmountTree fails to help
find the lingering process.
BUG=chromium:923432
TEST=Manually verified
Change-Id: I183ab7afb43858a3a377f090bc08b94615286a2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1613317
Tested-by: LaMont Jones <lamontjones@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Commit-Queue: LaMont Jones <lamontjones@chromium.org>
diff --git a/lib/cros_sdk_lib.py b/lib/cros_sdk_lib.py
index 8b257e7..358706c 100644
--- a/lib/cros_sdk_lib.py
+++ b/lib/cros_sdk_lib.py
@@ -394,7 +394,18 @@
# unmount it.
vg_name, _ = FindChrootMountSource(chroot, proc_mounts=proc_mounts)
- osutils.UmountTree(chroot)
+ try:
+ osutils.UmountTree(chroot)
+ except cros_build_lib.RunCommandError as e:
+ # TODO(lamontjones): Dump some information to help find the process still
+ # inside the chroot, causing crbug.com/923432. In the end, this is likely
+ # to become fuser -k.
+ fuser = cros_build_lib.SudoRunCommand(['fuser', chroot], error_code_ok=True)
+ lsof = cros_build_lib.SudoRunCommand(['lsof', chroot], error_code_ok=True)
+ ps = cros_build_lib.RunCommand(['ps', 'auxf'], error_code_ok=True)
+ raise Error(
+ 'Umount failed: %s.\nfuser output=%s\nlsof output=%s\nps output=%s\n',
+ e.result.error, fuser.output, lsof.output, ps.output)
# Find the loopback device by either matching the VG or the image.
chroot_dev = None