From a1dd57e11486c9ac395a74c3beb189da5b9288e8 Mon Sep 17 00:00:00 2001 From: hamistao Date: Tue, 10 Dec 2024 20:06:15 -0300 Subject: [PATCH 1/2] tests: Tests for getting VM root disk size Signed-off-by: hamistao --- tests/storage-vm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/storage-vm b/tests/storage-vm index 631e4dd6..2ddfabbd 100755 --- a/tests/storage-vm +++ b/tests/storage-vm @@ -599,6 +599,53 @@ for poolDriver in $poolDriverList; do [ "$(($(lxc exec v1 -- blockdev --getsize64 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_lxd_root) / GiB))" -eq "16" ] fi + lxc stop -f v1 + # Set 'volume.size' and create new VM + lxc storage set "${poolName}" volume.size="7GiB" + lxc init -s "${poolName}" testimage v3 + + # Get instance root disk sizes + [ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ] + [ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "7GiB" ] + + # Check volume 'size' and volume state also show correct total size. + [ "$(lxc storage volume get virtual-machine/v1 size)" = "10GiB" ] + [ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "10GiB" ] + [ "$(lxc storage volume get virtual-machine/v3 size)" = "7GiB" ] + [ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "7GiB" ] + + # Shrinking v1 is not allowed, grow v1 and v3. + # Device size should override default size and 'volume.size'. + lxc start v1 + lxc start v3 + ! lxc config device set v1 root size="7GiB" || false + ! lxc storage volume set virtual-machine/v1 size="11GiB" || false + lxc config device set v1 root size="11GiB" + lxc config device set v3 root size="10GiB" + + # Resizing does not apply while instance is running. + [ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ] + [ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "7GiB" ] + + # While instance is stopped, show new instance root disk size even though + # The volume itself only gets resized on instance start. + lxc stop -f v1 v3 + [ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "11GiB" ] + [ "$(lxc storage volume get virtual-machine/v1 volatile.rootfs.size)" = "10GiB" ] + [ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "10GiB" ] + + [ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ] + [ "$(lxc storage volume get virtual-machine/v3 volatile.rootfs.size)" = "7GiB" ] + [ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "7GiB" ] + + # Volume gets resized on start, + lxc start v1 + [ "$(lxc storage volume get virtual-machine/v1 volatile.rootfs.size)" = "11GiB" ] + [ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "11GiB" ] + + [ "$(lxc storage volume get virtual-machine/v3 volatile.rootfs.size)" = "10GiB" ] + [ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "10GiB" ] + echo "===> Renaming VM" lxc stop -f v1 lxc rename v1 v1renamed From 7635b44cb177a3c3c3f4e014eaf2ffdd54abb156 Mon Sep 17 00:00:00 2001 From: hamistao Date: Tue, 10 Dec 2024 20:12:12 -0300 Subject: [PATCH 2/2] WIP Signed-off-by: hamistao --- .github/workflows/tests.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 091b9971..506211a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -286,7 +286,22 @@ jobs: src_track="$(echo "${dst_track}" | cut -d/ -f1)/stable" EXTRA_ARGS="${EXTRA_ARGS:-3} ${src_track} ${{ matrix.track }}" fi - sudo --preserve-env=GITHUB_ACTIONS,GITHUB_STEP_SUMMARY,TEST_IMG ./bin/local-run "tests/${TEST_SCRIPT}" ${{ matrix.track }} ${EXTRA_ARGS:-} + + git clone https://github.com/hamistao/lxd + cd lxd + git checkout disk_size_fixes + sudo apt update + sudo apt install acl attr autoconf automake dnsmasq-base git libacl1-dev libcap-dev liblxc1 liblxc-dev libsqlite3-dev libtool libudev-dev liblz4-dev libuv1-dev make pkg-config rsync squashfs-tools tar tcl xz-utils ebtables + command -v snap >/dev/null || sudo apt-get install snapd + sudo snap install --classic go + make deps + export CGO_CFLAGS="-I/home/runner/go/deps/dqlite/include/" + export CGO_LDFLAGS="-L/home/runner/go/deps/dqlite/.libs/" + export LD_LIBRARY_PATH="/home/runner/go/deps/dqlite/.libs/" + export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" + make + cd .. + sudo LXD_SIDELOAD_PATH=/home/runner/go/bin/lxd --preserve-env=GITHUB_ACTIONS,GITHUB_STEP_SUMMARY,TEST_IMG ./bin/local-run "tests/${TEST_SCRIPT}" ${{ matrix.track }} ${EXTRA_ARGS:-} # always update cache as we have our own logic of # cache invalidation and updates in addition to a date check