From e2766bfab9051c66c99cdb77fe9195e3f1b1a904 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Tue, 27 Feb 2024 16:24:39 -0500 Subject: [PATCH] fix(util): Check if the zpool command is available before using it Fixes LP: #2055219 Signed-off-by: Simon Deziel --- cloudinit/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cloudinit/util.py b/cloudinit/util.py index 569f3ed9e61..82f36da722f 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -2670,6 +2670,11 @@ def get_device_info_from_zpool(zpool): if not os.path.exists("/dev/zfs"): LOG.debug("Cannot get zpool info, no /dev/zfs") return None + if not subp.which("zpool"): + # lxd containers may have /dev/zfs but not necessarily the zpool + # command available (LP: #2055219) + LOG.debug("Cannot get zpool info, no zpool command available") + return None try: (zpoolstatus, err) = subp.subp(["zpool", "status", zpool]) except subp.ProcessExecutionError as err: