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 <kyle.macleod@windriver.com>
This commit is contained in:
Kyle MacLeod 2023-05-19 21:24:45 -04:00
parent 1455771c9c
commit d807f6b65e
1 changed files with 16 additions and 18 deletions

View File

@ -1103,30 +1103,28 @@ if check_prestage -eq 0 ; then
ilog "Searching for existing installation..." 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 for part in "${part_numbers[@]}"; do
device=${rootfs_part_prefix}${part} device_list+=("${rootfs_part_prefix}${part}")
device_list+=(${device})
ilog "Adding ${device}"
done done
# adding the following device to the device list to search ilog "Checking device_list: ${device_list[*]}"
# for the filesystem. If Volume Groups have been enabled, for device in "${device_list[@]}"; do
# 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
# mount this part at a temporary mount point # mount this part at a temporary mount point
mount ${device} ${temp_mount} ilog "Checking device: ${device}"
if [ $? -ne 0 ]; then mount "${device}" "${temp_mount}"
wlog "Unable to mount ${device}" rc=$?
if [ "${rc}" -ne 0 ]; then
wlog "Unable to mount ${device}, rc=${rc}"
continue continue
fi fi
# Check for the presence of install_uuid in one of the partitions on # Check for the presence of install_uuid in one of the partitions on the device_list
# the root device if [ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]; then
if [[ -e "${temp_mount}/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid" ]]; then
wlog "Found valid installation on ${device}" wlog "Found valid installation on ${device}"
umount ${temp_mount} umount ${temp_mount}
# Do not modify the system in any way # Do not modify the system in any way