From dc3bfbf1643e877d027258480441ecfa2e72ee95 Mon Sep 17 00:00:00 2001 From: Shrikumar Sharma Date: Fri, 1 Apr 2022 14:25:02 -0400 Subject: [PATCH] Force installation of prestage iso when force_install option is provided through the kernel commandline When there is an existing installation on the subcloud, the kickstart will ensure that it is not overwritten by the prestaged iso. However, when the force_install option is provided via the kernel commandline, the existing installation can be overwritten. Test Plan: PASS: Verify that the prestage iso overwrites the existing installation when the force_install option is provided at the kernel commandline. PASS: Verify that the installation halts with a message, if there is an existing installation and force_install option is not provided at the kernel commandline. PASS: Verify that the prestage iso installs when there is no pre-existing installation and force_install is provided PASS: Verify that above tests pass on NVMe-based systems Regression: PASS: Verify that the prestage iso installs without force_install and no installation exists Story: 2009948 Task: 44914 Signed-off-by: Shrikumar Sharma Change-Id: I2491d80cb4e07aa2fb38381c9e92afd7549526ef --- .../pre_prestaging_install_check.cfg | 105 ++++++++++-------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/bsp-files/kickstarts/pre_prestaging_install_check.cfg b/bsp-files/kickstarts/pre_prestaging_install_check.cfg index e8627d66..8be8189e 100644 --- a/bsp-files/kickstarts/pre_prestaging_install_check.cfg +++ b/bsp-files/kickstarts/pre_prestaging_install_check.cfg @@ -11,56 +11,65 @@ wlog "pre prestaging install check" # First, parse /proc/cmdline to find the boot args set -- `cat /proc/cmdline` for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done +for J in $*; do case "$J" in force_install) force_install=${J};; esac; done -if [ -z "$rootfs_device" ]; then - rootfs_device=$(get_disk_dev) -fi +# if force_install is set, install anyway. Ignore the remainder of this section. -orig_rootfs_device=$rootfs_device -by_path_rootfs_device=$(get_by_path $rootfs_device) -rootfs_device=$(get_disk $by_path_rootfs_device) -wlog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device." - -part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') ) -# print the partnumber info for informational purposes -for i in ${part_numbers[@]}; do - wlog "partnumber: ${i}" -done - -# Get the correct rootfs prefix -ROOTFS_PART_PREFIX=${rootfs_device} -# check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix. -# for example, /dev/nvme0n1p1 -# so we need to add the letter "p" to get the prefix. -# The part numbers will be used later in the code. -case $rootfs_device in - *"nvme"*) - ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p - ;; -esac - -# temporary mount directory -temp_mount=/mnt - -wlog "Searching for existing installation..." -for part in "${part_numbers[@]}"; do - device=${ROOTFS_PART_PREFIX}${part} - wlog "Searching on ${device}" - # mount this part at a temporary mount point - mount ${device} ${temp_mount} - if [ $? -ne 0 ]; then - wlog "unable to mount ${device}" - continue +if [ -z ${force_install} ]; then + if [ -z "$rootfs_device" ]; then + rootfs_device=$(get_disk_dev) fi - # Check for the presence of install_uuid in one of the partitions on - # the root device - if [ -e ${temp_mount}/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid ]; then - wlog "Found valid installation on ${device}" + + orig_rootfs_device=$rootfs_device + by_path_rootfs_device=$(get_by_path $rootfs_device) + rootfs_device=$(get_disk $by_path_rootfs_device) + wlog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device." + + part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') ) + # print the partnumber info for informational purposes + for i in ${part_numbers[@]}; do + wlog "partnumber: ${i}" + done + + # Get the correct rootfs prefix + ROOTFS_PART_PREFIX=${rootfs_device} + # check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix. + # for example, /dev/nvme0n1p1 + # so we need to add the letter "p" to get the prefix. + # The part numbers will be used later in the code. + case $rootfs_device in + *"nvme"*) + ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p + ;; + esac + + # temporary mount directory + temp_mount=/mnt + + wlog "Searching for existing installation..." + for part in "${part_numbers[@]}"; do + device=${ROOTFS_PART_PREFIX}${part} + wlog "Searching on ${device}" + # mount this part at a temporary mount point + mount ${device} ${temp_mount} + if [ $? -ne 0 ]; then + wlog "unable to mount ${device}" + continue + fi + # Check for the presence of install_uuid in one of the partitions on + # the root device + if [ -e ${temp_mount}/var/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 + report_pre_failure_with_msg "Prestage rejected. Existing installation detected. Please eject the media before rebooting." + fi umount ${temp_mount} - # do not modify the system in any way - report_pre_failure_with_msg "Prestage rejected. Existing installation detected. Please eject the media before rebooting." - fi - wlog "Unmounting ${device}" - umount ${temp_mount} -done + done + 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 %end