diff --git a/.github/actions/quick-rpm-clean/action.yaml b/.github/actions/quick-rpm-clean/action.yaml index 2e0ca6b9..d58e249e 100644 --- a/.github/actions/quick-rpm-clean/action.yaml +++ b/.github/actions/quick-rpm-clean/action.yaml @@ -70,6 +70,20 @@ runs: # The command exits with the status of the service. sudo podman exec -i microshift-okd systemctl restart greenboot-healthcheck.service + - name: Verify LVM volume group is recreated on restart + shell: bash + run: | + set -euo pipefail + set -x + + sudo podman exec -i microshift-okd systemctl stop microshift.service + sudo podman exec -i microshift-okd vgremove myvg1 + sudo podman exec -i microshift-okd systemctl start microshift.service + + # Restart the greenboot service synchronously to check the health of the system. + # The command exits with the status of the service. + sudo podman exec -i microshift-okd systemctl restart greenboot-healthcheck.service + - name: Run the quick clean script if: ${{ inputs.run-clean == 'true' }} shell: bash diff --git a/src/quickclean.sh b/src/quickclean.sh index 66faecd9..898b8533 100755 --- a/src/quickclean.sh +++ b/src/quickclean.sh @@ -2,6 +2,7 @@ set -euo pipefail LVM_DISK="/var/lib/microshift-okd/lvmdisk.image" +LVM_CONFIG="/etc/systemd/system/microshift.service.d/99-lvm-config.conf" VG_NAME="myvg1" # Check if the script is running as root @@ -20,6 +21,13 @@ fi # Clean up the MicroShift data and uninstall RPMs if rpm -q microshift &>/dev/null ; then echo y | microshift-cleanup-data --all + + # Remove the LVM configuration + if [ -f "${LVM_CONFIG}" ] ; then + rm -f "${LVM_CONFIG}" + systemctl daemon-reload + fi + dnf remove -y 'microshift*' # Undo post-installation configuration rm -f /etc/sysctl.d/99-microshift.conf diff --git a/src/quickrpm.sh b/src/quickrpm.sh index 3128b612..55952233 100755 --- a/src/quickrpm.sh +++ b/src/quickrpm.sh @@ -93,9 +93,19 @@ function prepare_lvm_disk() { mkdir -p "$(dirname "${lvm_disk}")" truncate --size=1G "${lvm_disk}" +} + +function setup_lvm_service() { + local -r lvm_disk="$1" + local -r vg_name="$2" - local -r device_name="$(losetup --find --show --nooverlap "${lvm_disk}")" - vgcreate -f -y "${vg_name}" "${device_name}" + # Note that escaping quotes is necessary to avoid systemd parsing issues + mkdir -p /etc/systemd/system/microshift.service.d + cat > /etc/systemd/system/microshift.service.d/99-lvm-config.conf <