Skip to content

Conversation

@simondeziel
Copy link
Member

@simondeziel simondeziel commented Jun 11, 2025

This allows speeding up both CI and local dev envs using test-shell by pulling just the needed bits, when they are needed.

Lastly, it also hard fail if a mkfs binary is missing instead of skipping the test (too easy to miss).

Get a fresh VM in ~2 minutes:

$ time bash -c 'lxc launch ubuntu-minimal-daily:24.04 v1 --vm -p lxd-test; sleep 20; lxc exec v1 -- cloud-init status --wait'
Launching v1
..........status: done

real	1m38.078s
user	0m0.058s
sys	0m0.098s

Compile dqlite, liblxc and LXD in ~3.5 minutes:

$ lxc shell v1
root@v1:~# cd lxd
root@v1:~/lxd# time bash -c 'make deps && make'
...


real	3m18.779s
user	5m42.251s
sys	1m31.288s

Get a test-shell instantly:

root@v1:~/lxd# time LXD_BACKEND=zfs make test-shell
cd test && ./main.sh test-shell
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
   libnvpair3linux (2.2.2-0ubuntu9.2)
   libuutil3linux (2.2.2-0ubuntu9.2)
   libzfs4linux (2.2.2-0ubuntu9.2)
   libzpool5linux (2.2.2-0ubuntu9.2)
Suggested packages:
   nfs-kernel-server (1:2.6.4-3ubuntu5.1)
   samba-common-bin (2:4.19.5+dfsg-4ubuntu9)
   zfs-initramfs (2.2.2-0ubuntu9.2)
   | zfs-dracut (2.2.2-0ubuntu9.2)
Recommended packages:
   zfs-zed (2.2.2-0ubuntu9.2)
The following NEW packages will be installed:
   libnvpair3linux (2.2.2-0ubuntu9.2)
   libuutil3linux (2.2.2-0ubuntu9.2)
   libzfs4linux (2.2.2-0ubuntu9.2)
   libzpool5linux (2.2.2-0ubuntu9.2)
   zfsutils-linux (2.2.2-0ubuntu9.2)
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
...

==> Test result: success

real	0m9.534s
user	0m2.184s
sys	0m2.353s

@github-actions github-actions bot added the Documentation Documentation needs updating label Jun 11, 2025

This comment was marked as outdated.

@simondeziel simondeziel force-pushed the dynamic-storage-tools branch 2 times, most recently from e1e2e9f to fe31f4d Compare June 11, 2025 22:06
@simondeziel
Copy link
Member Author

* This key is duplicated (also defined on line 17); remove the redundant entry to avoid confusion.
APT::Get::Show-Versions "true";

This was actually a valid suggestion, thanks @copilot.

@simondeziel simondeziel force-pushed the dynamic-storage-tools branch from fe31f4d to 77a8bd1 Compare June 11, 2025 23:03
@simondeziel simondeziel requested a review from Copilot June 12, 2025 01:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the test and documentation frameworks to support on-demand installation of storage driver tools, ensuring that only the required bits are pulled when needed to speed up CI and local development.

  • Removed pre-checks for tool availability in test suites to enable dynamic installation
  • Updated test/main.sh to install missing packages based on the requested storage backend
  • Modified documentation and action files to reflect the new on-demand installation approach

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/suites/storage_driver_zfs.sh Removed mkfs tool check in favor of on-demand installation
test/suites/migration.sh Similarly removed mkfs tool check to align with updated installation flow
test/main.sh Added logic to install storage backend packages if not already available
doc/lxd-test.yaml & doc/installing.md Updated package lists to include additional dependencies
.github/actions/install-lxd-runtimedeps/action.yml Adjusted installation steps, removing some package installs for tools
Comments suppressed due to low confidence (4)

test/suites/storage_driver_zfs.sh:112

  • Removal of the mkfs tool check assumes that tools will be installed on-demand. Consider adding a comment to explain this behavior for future maintenance clarity.
if ! command -v "mkfs.${filesystem}" >/dev/null 2>&1; then

test/suites/migration.sh:51

  • Similar to the storage_driver_zfs.sh change, consider adding a comment explaining the removal of the mkfs tool check to clarify that missing tools are handled on-demand.
if ! command -v "mkfs.${fs}" >/dev/null 2>&1; then

test/main.sh:62

  • Consider adding error handling or logging if the attempted package installation fails, to provide clearer feedback during test execution.
elif ! available_storage_backends | grep -qwF "${LXD_BACKEND}"; then

.github/actions/install-lxd-runtimedeps/action.yml:13

  • The explicit installation of zfsutils-linux has been removed here. Confirm that on-demand installation in test/main.sh covers all required storage backends consistently.
zfsutils-linux

@simondeziel simondeziel marked this pull request as ready for review June 12, 2025 01:17
@simondeziel simondeziel force-pushed the dynamic-storage-tools branch from 77a8bd1 to d40093c Compare June 12, 2025 01:42
This avoids pulling 51 extra packages in the name of speed. If something's
needed, it needs to be explicitely added to the list of `packages`.

Signed-off-by: Simon Deziel <[email protected]>
It's faster than uninstalling their respective packages. Also stop worrying
about packages not present in `ubuntu-minimal-daily:24.04`.

Signed-off-by: Simon Deziel <[email protected]>
@simondeziel simondeziel force-pushed the dynamic-storage-tools branch from d40093c to 0d4aec4 Compare June 12, 2025 03:13
- content: "force-unsafe-io\n"
path: /etc/dpkg/dpkg.cfg
append: true
# Smaller initramfs (tailored to detected HW) and faster to build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it know which modules are needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update-initramfs tool has the smart to include the modules that are needed by the env it executes in.

However, you made me look again and the 24.04 minimal images are now booting without the usual initrd so this is dead code (I just dropped it). Thanks for catching this!

Server/physical machines running Noble (or VMs < 24.04) can still benefit from this trick as they keep using the traditional initrd. Here it is in action, with the various level of setting:

Regular, big == boots everywhere

root@mars:~# time update-initramfs -uk all
update-initramfs: Generating /boot/initrd.img-6.8.0-60-generic
...
real	0m8.063s
user	0m2.678s
sys	0m3.009s
root@mars:~# ll -h /boot/initrd.img-6.8.0-60-generic 
-rw-r--r-- 1 root root 62M Jun 12 09:09 /boot/initrd.img-6.8.0-60-generic

Tailored, smaller == boots only on ~identical machine

root@mars:~# echo MODULES=dep > /etc/initramfs-tools/conf.d/lxd-test.conf
root@mars:~# time update-initramfs -uk all
...
real	0m5.417s
user	0m1.467s
sys	0m2.668s
root@mars:~# ll -h /boot/initrd.img-6.8.0-60-generic 
-rw-r--r-- 1 root root 37M Jun 12 09:10 /boot/initrd.img-6.8.0-60-generic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into it, interesting stuff, TIL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the speed difference between default and MODULES=dep was much bigger but since 23.10, they changed it so that modules are already zstd compressed and building the initrd is now essentially just concatenating them as-is into a cpio archive. There is no re-compression like there used to be.

@simondeziel simondeziel force-pushed the dynamic-storage-tools branch from 0d4aec4 to 9f4752b Compare June 12, 2025 13:18
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tomponline tomponline merged commit 27a413b into canonical:main Jun 13, 2025
30 checks passed
@simondeziel simondeziel deleted the dynamic-storage-tools branch June 13, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Documentation needs updating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants