Allow opt-out of full ramdisk pruning

While aggressively pruning ramdisk contents reduces the size, it can
break packages that depend on any of the pruned directories existing.
Allow anyone impacted by that case to opt out.

Change-Id: I1b5a65a56d151a26ee44446c20c6df31bb695223
This commit is contained in:
Jay Faulkner 2021-08-09 14:51:52 -07:00
parent 8ba630fb22
commit 5c8fc6fd31
2 changed files with 53 additions and 25 deletions

View File

@ -3,3 +3,12 @@ ironic-ramdisk-base
This is a base element for ironic ramdisks. It does not install anything, just This is a base element for ironic ramdisks. It does not install anything, just
takes the prepared images and extract kernel/ramdisk from it. takes the prepared images and extract kernel/ramdisk from it.
Configurable Environment Variables
----------------------------------
- `DIB_IPA_COMPRESS_COMMAND` defaults to `gzip`, may be set to any valid
compression program usable for an initramfs
- `DIB_IPA_MINIMAL_PRUNE` defaults to `0` (false). If set to `1`, will skip
most ramdisk size optimizations. This may be helpful for use of packages
with IPA that require otherwise-pruned directories or files.

View File

@ -24,7 +24,25 @@ echo "#disabled" > ./tmp/fstab.new
sudo mv ./tmp/fstab.new ./etc/fstab sudo mv ./tmp/fstab.new ./etc/fstab
sudo ln -s ./sbin/init ./ sudo ln -s ./sbin/init ./
# Note: The pci.ids, which is used by lshw, locate on Ubuntu # Note(JayF): to anyone trying to make this more configurable in the future,
# there are significant hurdles around shell quoting if you try to put these
# find commands into variables for making them more configurable.
if [ "${DIB_IPA_MINIMAL_PRUNE:-0}" -gt 0 ]; then
# Operator opted out of full ramdisk pruning; do not proactively remove
# directories that may be in use by other elements/packages
sudo find . -xdev \
-path './sys/*' -prune -o \
-path './tmp/*' -prune -o \
-path './boot/*' -prune -o \
-path './root/.cache' -prune -o \
-name '*.pyc' -prune -o \
-name '*.pyo' -prune -o \
-print | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs
else
# This performs a full prune, leading to the smallest possible ramdisk
# size. This may break operator-configured packages or elements that
# depend on pruned paths.
# Note: The pci.ids, which is used by lshw, are located on Ubuntu
# in /usr/share/misc. Therefore we are removing only the # in /usr/share/misc. Therefore we are removing only the
# ./usr/share/misc/m* (will remove the magic and magic.mgc files). # ./usr/share/misc/m* (will remove the magic and magic.mgc files).
# on RHEL pci.ids is locate on /usr/share/hwdata/pci.ids. # on RHEL pci.ids is locate on /usr/share/hwdata/pci.ids.
@ -49,6 +67,7 @@ sudo find . -xdev \
-name '*.pyc' -prune -o \ -name '*.pyc' -prune -o \
-name '*.pyo' -prune -o \ -name '*.pyo' -prune -o \
-print | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs -print | sudo cpio -o -H newc | ${DIB_IPA_COMPRESS_CMD} > ${IMAGE_PATH}.initramfs
fi
select_boot_kernel_initrd $TARGET_ROOT select_boot_kernel_initrd $TARGET_ROOT
sudo cp $BOOTDIR/$KERNEL ${IMAGE_PATH}.kernel sudo cp $BOOTDIR/$KERNEL ${IMAGE_PATH}.kernel