Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lxd do not check for thinpool kernel module #5709

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 0 additions & 4 deletions tests/unittests/config/test_cc_lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ def test_lxd_init(self, maybe_clean, which, subp, exists, system_info):
self.assertEqual(
[
mock.call(sem_file),
mock.call(
"/lib/modules/mykernel/"
"kernel/drivers/md/dm-thin-pool.ko"
),
],
exists.call_args_list,
)
Expand Down