From d807f6b65e689055f1328fd56c0d3daca0cc603e Mon Sep 17 00:00:00 2001 From: Kyle MacLeod Date: Fri, 19 May 2023 21:24:45 -0400 Subject: [PATCH] Fix prestage ISO install abort if previous subcloud install exists This commit fixes the detection of www/pages/feed/rel-xx.x/install_uuid via device '/dev/cgts-vg/var-lv'. There was a bug which was always mounting the same device, rather than the proper device_list. The code is also slightly refactored for simplification and clarity. Test Plan PASS: - Generate ISO using gen-prestage-iso.sh without --force-install option - Verify installation failure (drop to boot prompt) if previous subcloud installation exists - Verify successful subcloud installation if no previous subcloud installation exists - Generate ISO using gen-prestage-iso.sh with --force-install option - Verify successful installation regardless if previous subcloud installation exists or not Closes-Bug: 2020526 Change-Id: Ib83d72fa07335ffa29d365da7813b226c4ef310b Signed-off-by: Kyle MacLeod --- kickstart/files/kickstart.cfg | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/kickstart/files/kickstart.cfg b/kickstart/files/kickstart.cfg index 54554b0b..2369f0bb 100644 --- a/kickstart/files/kickstart.cfg +++ b/kickstart/files/kickstart.cfg @@ -1103,30 +1103,28 @@ if check_prestage -eq 0 ; then ilog "Searching for existing installation..." - device_list=() + # Build up device_list to search for existing installation. + # We will look for the install_uuid file on each of the devices in the list. + # First, if volume groups have been enabled, we can mount /dev/cgts-vg/var-lv + device_list=("/dev/cgts-vg/var-lv") + + # Now add the rest of the rootfs partitions to device_list for part in "${part_numbers[@]}"; do - device=${rootfs_part_prefix}${part} - device_list+=(${device}) - ilog "Adding ${device}" + device_list+=("${rootfs_part_prefix}${part}") done - # adding the following device to the device list to search - # for the filesystem. If Volume Groups have been enabled, - # it is possible to perform the checks for install_guid below - # by mounting /dev/cgts-vg/var-lv. - device_list+=("/dev/cgts-vg/var-lv") - ilog "Adding /dev/cgts-vg/var-lv" - - for part in "${device_list[@]}"; do + ilog "Checking device_list: ${device_list[*]}" + for device in "${device_list[@]}"; do # mount this part at a temporary mount point - mount ${device} ${temp_mount} - if [ $? -ne 0 ]; then - wlog "Unable to mount ${device}" + ilog "Checking device: ${device}" + mount "${device}" "${temp_mount}" + rc=$? + if [ "${rc}" -ne 0 ]; then + wlog "Unable to mount ${device}, rc=${rc}" continue fi - # Check for the presence of install_uuid in one of the partitions on - # the root device - if [[ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]]; then + # Check for the presence of install_uuid in one of the partitions on the device_list + if [ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]; then wlog "Found valid installation on ${device}" umount ${temp_mount} # Do not modify the system in any way