miniboot: Use release-specific prestage data, handle subcloud downgrade

This commit handles the relocation of ostree_repo prestaging data from
/opt/platform-backup to /opt/platform-backup/<release>. The miniboot.cfg
kickstart now looks for prestaged data in the release-specific location.

We also handle the backup partition name change across CentOS/Debian. In
the case of a downgrade the CentOS miniboot kickstart code is updated to
use the partition GUID rather than LABEL or PARTLABEL. The GUID is
constant across all releases and is therefore a more reliable indicator
of the backup partition.

Tech debt: Fix the arbitrary wait sleep calls used when configuring
VLAN addressing. Now uses the more efficient wait_for_interface
approach for the VLAN links.

Test Plan
PASS:
- Boot with prestaged data under /opt/platform-backup/<release>/
  Ensure boot/install successfully uses prestaged data.
- Boot into older release under prestaged /opt/platform-backup/21.12
    - Test moving from 22.12 -> 21.12 and 21.12 -> 22.12
    - Ensure backup partition is found using GUID approach.
    - Ensure boot/install successfully uses prestaged data.
- Boot into both current and older release with no prestaged data
    - Test moving from 22.12 -> 21.12 and 21.12 -> 22.12
    - Ensure boot/install is successful.
- Boot subcloud with bootstrap_vlan, ensure that the wait_for_interface
  calls properly wait until the link is up.

Story: 2010611
Task: 47943
Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/880789

Change-Id: I381b60285e9bfc375f01f45b79174b71da7f0565
Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
This commit is contained in:
Kyle MacLeod 2023-05-04 17:31:09 -04:00
parent 5babe39c78
commit 018d06ccec
2 changed files with 27 additions and 19 deletions

View File

@ -58,8 +58,8 @@
SW_VERSION=xxxPLATFORM_RELEASExxx SW_VERSION=xxxPLATFORM_RELEASExxx
STAGING_DIR="platform-backup" STAGING_DIR="platform-backup"
BACKUP_PART_LABEL=Platform\\x20Backup BACKUP_DEVICE=
BACKUP_DEVICE=/dev/disk/by-partlabel/${BACKUP_PART_LABEL} BACKUP_PART_GUID="BA5EBA11-0000-1111-2222-000000000002"
BACKUP_MOUNT=/mnt/${STAGING_DIR} BACKUP_MOUNT=/mnt/${STAGING_DIR}
BOOTIMAGE_ISO="" BOOTIMAGE_ISO=""
@ -76,8 +76,17 @@ iso_check=false
iso_mount=false iso_mount=false
prestaging_files=false prestaging_files=false
# Search for a backup partition, using GUID (which appears lower case in the blkid output):
while read -r device_path; do
if [ "$(blkid -p "${device_path}" | grep -c -i "${BACKUP_PART_GUID}")" -gt 0 ]; then
BACKUP_DEVICE=${device_path}
wlog "Found backup device: ${BACKUP_DEVICE}"
break
fi
done <<<"$(lsblk --noheadings --list --path --output NAME)"
# Look for and validate the local iso image # Look for and validate the local iso image
if [ -e ${BACKUP_DEVICE} ]; then if [ -n "${BACKUP_DEVICE}" ] && [ -e "${BACKUP_DEVICE}" ]; then
mkdir -p ${BACKUP_MOUNT} mkdir -p ${BACKUP_MOUNT}
mount ${BACKUP_DEVICE} ${BACKUP_MOUNT} 2>/dev/null mount ${BACKUP_DEVICE} ${BACKUP_MOUNT} 2>/dev/null
rc=$? rc=$?
@ -183,6 +192,7 @@ fi
# Make sure the prestage directory exists, as well as the required subdirectories. # Make sure the prestage directory exists, as well as the required subdirectories.
exists_prestage=false exists_prestage=false
ilog "${KS} Checking prestaged content PRESTAGE_DIR: ${PRESTAGE_DIR}"
if [ ! -e ${PRESTAGE_DIR} ] || [ ! -e ${PRESTAGE_DIR}/Packages ] || [ ! -e ${PRESTAGE_DIR}/repodata ]; then if [ ! -e ${PRESTAGE_DIR} ] || [ ! -e ${PRESTAGE_DIR}/Packages ] || [ ! -e ${PRESTAGE_DIR}/repodata ]; then
exists_prestage=false exists_prestage=false
wlog "${KS} Prestaged content not present" wlog "${KS} Prestaged content not present"

View File

@ -1582,13 +1582,10 @@ else
fi fi
ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev}" ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev}"
ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev} ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev}
# TODO(kmacleod) change to wait_for_interface 60: wait_for_interface ${mgmt_dev} 60
sleep 15
ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}" ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}"
ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface} ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}
# TODO(kmacleod) change to wait_for_interface 60: wait_for_interface ${mgmt_iface} 60
ilog "Wait 10s to settle interface..."
sleep 10
if [ -z "${BOOTPARAM_GW}" ]; then if [ -z "${BOOTPARAM_GW}" ]; then
# No gateway # No gateway
@ -2049,28 +2046,29 @@ else
backup_device=/dev/disk/by-partlabel/platform_backup backup_device=/dev/disk/by-partlabel/platform_backup
backup_mount=/tmp/platform-backup backup_mount=/tmp/platform-backup
backup_mount_release="${backup_mount}"/xxxPLATFORM_RELEASExxx
ilog "Temporary backup mount is ${backup_mount}" ilog "Temporary backup mount: ${backup_mount}, release: ${backup_mount_release}"
mkdir -p "${backup_mount}" mkdir -p "${backup_mount}"
mount "${backup_device}" "${backup_mount}" 2>/dev/null mount "${backup_device}" "${backup_mount}" 2>/dev/null
# If ostree_repo is found at the mounted backup directory, # If ostree_repo is found at the mounted backup directory,
# then set the ostree url to its location. # then set the ostree url to its location.
remote_insturl= remote_insturl=
if [ -e ${backup_mount}/ostree_repo ]; then if [ -e ${backup_mount_release}/ostree_repo ]; then
local_repo_check_fail= local_repo_check_fail=
# Calculate local checksum and compare # Calculate local checksum and compare
checksum_file=${backup_mount}/.ostree_repo_checksum checksum_file=${backup_mount_release}/.ostree_repo_checksum
if [ -f "${checksum_file}" ]; then if [ -f "${checksum_file}" ]; then
checksum_from_file=$(cat "${checksum_file}") checksum_from_file=$(cat "${checksum_file}")
ilog "Verifying checksum for prestaged ${backup_mount}/ostree_repo" ilog "Verifying checksum for prestaged ${backup_mount_release}/ostree_repo"
pushd ${backup_mount} > /dev/null pushd ${backup_mount_release} > /dev/null
checksum=$(find ostree_repo -type f -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1; }') checksum=$(find ostree_repo -type f -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1; }')
popd > /dev/null popd > /dev/null
if [ "${checksum}" = "${checksum_from_file}" ]; then if [ "${checksum}" = "${checksum_from_file}" ]; then
ilog "Verified ostree checksum: ${checksum}" ilog "Verified ostree checksum: ${checksum}"
else else
elog "ostree checksum failed on ${backup_mount}/ostree_repo" elog "ostree checksum failed on ${backup_mount_release}/ostree_repo"
elog "Calulated checksum: ${checksum}" elog "Calulated checksum: ${checksum}"
elog "File checksum: ${checksum_from_file}" elog "File checksum: ${checksum_from_file}"
local_repo_check_fail=true local_repo_check_fail=true
@ -2079,8 +2077,8 @@ else
# No prestage checksum file is available. Use ostree fsck instead. # No prestage checksum file is available. Use ostree fsck instead.
# The only problem with this is the length of time required for fsck to complete. # The only problem with this is the length of time required for fsck to complete.
wlog "No ostree checksum file at ${checksum_file}. Performing ostree fsck instead." wlog "No ostree checksum file at ${checksum_file}. Performing ostree fsck instead."
if ! ostree --repo="${backup_mount}/ostree_repo" fsck; then if ! ostree --repo="${backup_mount_release}/ostree_repo" fsck; then
elog "ostree fsck failed on prestaged ${backup_mount}/ostree_repo: reverting to remote pull" elog "ostree fsck failed on prestaged ${backup_mount_release}/ostree_repo: reverting to remote pull"
local_repo_check_fail=true local_repo_check_fail=true
fi fi
fi fi
@ -2088,13 +2086,13 @@ else
# Preserve remote_insturl for use in 2nd ostree pull below # Preserve remote_insturl for use in 2nd ostree pull below
remote_insturl=${insturl} remote_insturl=${insturl}
insturl="file:///${backup_mount}/ostree_repo" insturl="file:///${backup_mount_release}/ostree_repo"
ilog "Setting insturl to ${insturl} to use prestaged ostree_repo" ilog "Setting insturl to ${insturl} to use prestaged ostree_repo"
else else
# Remove the corrupted ostree_repo. # Remove the corrupted ostree_repo.
# Avoid setting insturl which will revert to using a remote pull # Avoid setting insturl which will revert to using a remote pull
elog "ostree integrity check failed: removing prestaged ${backup_mount}/ostree_repo" elog "ostree integrity check failed: removing prestaged ${backup_mount_release}/ostree_repo"
rm -rf "${backup_mount}/ostree_repo" rm -rf "${backup_mount_release}/ostree_repo"
elog "ostree integrity check failed: reverting to remote pull" elog "ostree integrity check failed: reverting to remote pull"
fi fi
fi fi