diff --git a/etc/systemd/system/var-lib-linstor.service b/etc/systemd/system/var-lib-linstor.service index e9deb9042..c5e6e5bcd 100644 --- a/etc/systemd/system/var-lib-linstor.service +++ b/etc/systemd/system/var-lib-linstor.service @@ -19,3 +19,5 @@ Type=oneshot ExecStart=/bin/mount -w /dev/drbd/by-res/xcp-persistent-database/0 /var/lib/linstor ExecStop=/opt/xensource/libexec/safe-umount /var/lib/linstor RemainAfterExit=true +StandardOutput=journal +StandardError=inherit diff --git a/scripts/safe-umount b/scripts/safe-umount index 3c64a3f31..f51d8672b 100755 --- a/scripts/safe-umount +++ b/scripts/safe-umount @@ -18,7 +18,7 @@ def safe_umount(path): return 0 proc = subprocess.Popen(['umount', path], stderr=subprocess.PIPE) - (stdout, stderr) = proc.communicate() + (_stdout, stderr) = proc.communicate() if not proc.returncode: return 0 @@ -29,7 +29,22 @@ def safe_umount(path): retry_count -= 1 last_code = proc.returncode time.sleep(0.500) - return last_code + + # Lazy attempt. + # Unmounting can fail for example due to a network outage of a DRBD volume mounted + # as `xcp-persistent-database` and which would be blocked in the kernel because of + # ext4 commands that cannot complete. + # In this kind of situation, it's necessary to force a umount call with lazy arg to + # ensure that the mountpoint does not remain present. + print(f'Failed to unmount `{path}`, trying with lazy option...', file=sys.stderr) + proc = subprocess.Popen(['umount', '-l', path], stderr=subprocess.PIPE) + (_stdout, stderr) = proc.communicate() + if proc.returncode: + print(f'Failed to unmount `{path}` with lazy option: `{stderr.strip()}`.', file=sys.stderr) + else: + print(f'Successfully unmounted `{path}`.', file=sys.stderr) + + return proc.returncode if __name__ == '__main__':