Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/quick-rpm-clean/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/quickclean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 14 additions & 3 deletions src/quickrpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
[Service]
ExecStartPre=/bin/bash -c 'vgs "${vg_name}" || vgcreate -f -y "${vg_name}" "\$(losetup --find --show --nooverlap "${lvm_disk}")"'
EOF
systemctl daemon-reload
}
Comment thread
ggiguash marked this conversation as resolved.

function start_microshift() {
Expand Down Expand Up @@ -123,7 +133,8 @@ fi
check_prerequisites
centos10_cni_plugins
install_rpms
prepare_lvm_disk "${LVM_DISK}" "${VG_NAME}"
prepare_lvm_disk "${LVM_DISK}" "${VG_NAME}"
setup_lvm_service "${LVM_DISK}" "${VG_NAME}"
start_microshift
Comment thread
coderabbitai[bot] marked this conversation as resolved.

# Follow-up instructions
Expand Down
Loading