← Back to team overview

curtin-dev team mailing list archive

[Merge] ~ogayot/curtin:nvmeotcp-poc-blacklist-initramfs-tools into curtin:master

 

Olivier Gayot has proposed merging ~ogayot/curtin:nvmeotcp-poc-blacklist-initramfs-tools into curtin:master.

Commit message:
do not squash

Requested reviews:
  curtin developers (curtin-dev)
Related bugs:
  Bug #2073125 in subiquity: "initramfs-tools gets reinstalled over initramfs-tools when using NVMe/TCP with firmware support"
  https://bugs.launchpad.net/subiquity/+bug/2073125

For more details, see:
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/473058

NVMe/TCP POC: Prevent initramfs-tools from overwriting dracut

For the NVMe/TCP POC, we install dracut over initramfs-tools. However, when installing the linux-generic package later on, initramfs-tools gets pulled back to the system, replacing dracut.

This is because we install recommended packages and intel-microcode (pulled by linux-generic) has initramfs-tools as a recommends.

Although we could technically do something like `apt install linux-generic dracut` to avoid dracut removal, it is likely that at some point (either during an upgrade or installation of another package), something will cause removal of dracut - making the system unable to boot.

Therefore, we use APT pinning to make sure initramfs-tools does not get installed.

I also had to skip the call to update-initramfs at the end of the curthooks; since the presence of dracut would make this call fail.

LP: #2073125
-- 
Your team curtin developers is requested to review the proposed merge of ~ogayot/curtin:nvmeotcp-poc-blacklist-initramfs-tools into curtin:master.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 0539c83..c364cdf 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -1555,6 +1555,25 @@ def configure_nvme_over_tcp(cfg, target: pathlib.Path) -> None:
         # jq is needed for the nvmf dracut module.
         distro.install_packages(['dracut', 'dracut-network', 'jq'],
                                 target=str(target))
+        # Let's make sure initramfs-tools does not get reinstalled over dracut.
+        # intel-microcode (pulled by linux-generic) is known to have
+        # initramfs-tools as a recommends. LP: #2073125
+        (target / 'etc/apt/preferences.d').mkdir(parents=True, exist_ok=True)
+        (target / 'etc/apt/preferences.d/nvmeotcp-poc-initramfs').write_text(
+'''\
+# The NVMe/TCP proof of concept on Ubuntu uses dracut instead of
+# initramfs-tools.
+# That said, dracut is a universe package and is not the supported tool for
+# initramfs management. Installing packages that explicitly depend on
+# initramfs-tools will cause dracut to be removed, making the system unable to
+# boot. Furthermore, installing packages that have initramfs-tools as a
+# recommends can also trigger removal of dracut. Let's make sure
+# initramfs-tools does not get installed. See LP: #2073125.
+
+Package: initramfs-tools
+Pin: version *
+Pin-Priority: -1
+''')
         # This will take care of reading the network configuration from the
         # NBFT and pass it to systemd-networkd.
         nvme_tcp.dracut_add_systemd_network_cmdline(target)
@@ -1953,7 +1972,13 @@ def builtin_curthooks(cfg, target, state):
         if osfamily == DISTROS.debian:
             # re-enable update_initramfs
             enable_update_initramfs(cfg, target, machine)
-            update_initramfs(target, all_kernels=True)
+            if not (pathlib.Path(target) / 'usr/bin/dracut').exists():
+                update_initramfs(target, all_kernels=True)
+            else:
+                # For the NVMe/TCP POC, we don't have initramfs-tools anymore
+                # at this point and dracut was not diverted, so no need to
+                # re-run it.
+                pass
         elif osfamily == DISTROS.redhat:
             redhat_update_initramfs(target, cfg)
 

Follow ups