Delete Platform Backup partition first when installing Prestage iso

The size of a subcloud's platform backup partition can be increased
from a minimum of 30GB using a persistent_size entry in the file
install_values.yaml.

However, a failure to install prestage.iso is observed when a subcloud
has a platform backup partition size greater than 30GB. The failure to
install the prestage iso occurs, because "parted" attempts, by default
to create a 30GB platform backup partition in the prestaging kickstart.
"parted" fails when it encounters a partition size greater than 30GB.

This fix addresses this issue by always deleting the partition before
prestaging. This allows parted to create the partition with the default
value of 30GB, irrespective of what existed there previously.

Test Plan:
PASS: Verify that prestage ISO installation succeeds when the
      partition size of Platform Backup is greater than 30GB.

Regression:
PASS: Verify that prestage ISO installation succeeds when the
      force-install option is provided to gen_prestage_iso.sh

PASS: Verify that prestage ISO installation succeeds when the
      force-install option is not provided to gen_prestage_iso.sh
      and there is no pre-existing installation on the subcloud.

PASS: Verify that prestage ISO installation fails when the
      force-install option is not provided to gen_prestage_iso.sh
      and there is a pre-existing installation on the subcloud.

Closes-Bug: 1977975

Change-Id: I34fbf7bc6fb550deaee26e5c9a71402611834aa8
Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
This commit is contained in:
Shrikumar Sharma 2022-06-07 20:37:05 -04:00
parent d92914b9f2
commit f1694be26d

View File

@ -18,7 +18,7 @@ if [ -e /run/install/repo/ks-setup.cfg ]; then
fi
# if force_install is set, install anyway. Ignore the remainder of this section.
if [ -z ${force_install} ]; then
if [ -z "${force_install}" ]; then
if [ -z "$rootfs_device" ]; then
rootfs_device=$(get_disk_dev)
fi
@ -47,7 +47,8 @@ if [ -z ${force_install} ]; then
esac
# temporary mount directory
temp_mount=/mnt
temp_mount=/mnt/temp_mount
mkdir -p ${temp_mount}
wlog "Searching for existing installation..."
for part in "${part_numbers[@]}"; do
@ -69,10 +70,35 @@ if [ -z ${force_install} ]; then
fi
umount ${temp_mount}
done
rm -rf ${temp_mount}
wlog "Installing Prestaged content. No existing installation found."
else
# force install inspite of existing installation
wlog "Force install the prestage content"
wlog "Installing Prestaged content. All existing installations will be lost."
fi
# If the size of the Platform Backup partition is greater than 30GB, parted will fail when
# it tries to reconfigure the partition in a later step. We delete the partition now so that
# parted succeeds in the later step.
partition_id=$(parted -s ${rootfs_device} print | awk '/Platform Backup/ { print $1; }')
# if the partition id is not empty or zero, then the partition actually exists.
# Delete the partition.
if [[ "${partition_id}" -ne '' && "${partition_id}" -ne "0" ]]; then
wlog "Deleting platform backup at partition ${partition_id} on ${rootfs_device}"
# Delete the platform backup partition
parted -s ${rootfs_device} rm ${partition_id}
rc=$?
if [ "${rc}" -ne "0" ]; then
wlog "Unable to delete platform backup at partition ${partition_id} on ${rootfs_device}: [exit code ${rc}]"
exit -1
else
wlog "Deleted partition ${partition_id} on ${rootfs_device}"
fi
fi
%end