Skip to content

Commit

Permalink
fix: lxd do not check for thinpool kernel module
Browse files Browse the repository at this point in the history
Rather than checking for kernel module file before running lxd, just
fall back to disabling thinpool and retrying with thinpool disabled
when cloud-init fails and it is using lvm as backing storage.

On some Ubuntu releases, the kernel module is compressed which causes
this check to fail and this warning to erroneously be logged.
  • Loading branch information
holmanb committed Sep 16, 2024
1 parent 654cb44 commit 6e53cb6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions cloudinit/config/cc_lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
"trust_password",
)

# Bug https://bugs.launchpad.net/ubuntu/+source/linux-kvm/+bug/1982780
kernel = util.system_info()["uname"][2]
if init_cfg["storage_backend"] == "lvm" and not os.path.exists(
f"/lib/modules/{kernel}/kernel/drivers/md/dm-thin-pool.ko"
):
cmd = ["lxd", "init", "--auto"]
for k in init_keys:
if init_cfg.get(k):
cmd.extend(
["--%s=%s" % (k.replace("_", "-"), str(init_cfg[k]))]
)
try:
subp.subp(cmd)
except subp.ProcessExecutionError:
if init_cfg["storage_backend"] != "lvm":
raise
LOG.warning(
"cloud-init doesn't use thinpool by default on Ubuntu due to "
"LP #1982780. This behavior will change in the future.",
Expand All @@ -145,14 +151,9 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
init_keys = tuple(
key for key in init_keys if key != "storage_backend"
)

cmd = ["lxd", "init", "--auto"]
for k in init_keys:
if init_cfg.get(k):
cmd.extend(
["--%s=%s" % (k.replace("_", "-"), str(init_cfg[k]))]
)
subp.subp(cmd)
# Retry with thinpool in case of minimal image
# Bug https://bugs.launchpad.net/ubuntu/+source/linux-kvm/+bug/1982780
subp.subp(cmd)

# Set up lxd-bridge if bridge config is given
dconf_comm = "debconf-communicate"
Expand Down

0 comments on commit 6e53cb6

Please sign in to comment.