Handle prestage partition create and cleanup when needed
This update ensures the 'Platform Backup' partition label is assigned to a newly created partition so that it gets mounted properly. This update cleans the prestage directory prior to new prestaging. Test Plan: PASS: Verify prestaging partition create if missing PASS: Verify prestaging cleanup before staging new files PASS: Verify prestaged failure handling with small disk. PASS: Verify prestaging image install and login. PASS: Verify back to back prestaging installs PASS: Verify reboot recovery after prestaging install Story: 2009291 Task: 43825 Change-Id: I8f51b9d91ba7fd32e722a37f8336397959ba6ed6 Depends-On: https://review.opendev.org/c/starlingx/metal/+/817779 Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
parent
728161d9a9
commit
e4d4fec506
@ -158,13 +158,18 @@ function exec_retry()
|
||||
return \${ret_code}
|
||||
}
|
||||
|
||||
# debug / fit support tool
|
||||
# This is a developer debug tool that can be line inserted in any kickstart.
|
||||
# Code should not be committed with a call to this function.
|
||||
# When inserted and hit, execution will stall until one of the 2 conditions:
|
||||
# 1. /tmp/wait_for_go file is removed 'manually'
|
||||
# 2. or after 10 minutes
|
||||
|
||||
function wait_for_go()
|
||||
{
|
||||
for loop in {1..40} ; do
|
||||
sleep 15
|
||||
if [ -e "/tmp/go" ] ; then
|
||||
rm "/tmp/go"
|
||||
touch /tmp/wait_for_go
|
||||
for loop in {1..60} ; do
|
||||
sleep 10
|
||||
if [ ! -e "/tmp/wait_for_go" ] ; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -1,9 +1,41 @@
|
||||
%pre --erroronfail
|
||||
%post --nochroot --erroronfail
|
||||
|
||||
# Source common functions
|
||||
. /tmp/ks-functions.sh
|
||||
KS="Prestaging post:"
|
||||
|
||||
KS="Prestaging pre :"
|
||||
#
|
||||
# The /tmp/backup-guid-change.sh script assignes the Label
|
||||
# and GUID to the Platform Backup partition. This script is
|
||||
# dynamically created in the pre_disk_aio.cfg kickstart, which
|
||||
# serves as the disk setup kickstart for the prestaging bundle.
|
||||
#
|
||||
# However, this script is only run afterward; in post_common.cfg
|
||||
# which is not used in the prestaging bundle ; it contains too
|
||||
# much in-service controller function setup stuff.
|
||||
#
|
||||
# Therefore, it is added here to ensure that if the prestaging
|
||||
# ISO's pre_disk_aio.cfg 'created' the 'Platform Backup'
|
||||
# partition then it will get labeled for prestaging group.
|
||||
#
|
||||
# This prestaging kickstart file uses the 'label' to find the
|
||||
# 'Platform Backup' partition for its prestaging function.
|
||||
#
|
||||
change_guid=/tmp/backup-guid-change.sh
|
||||
if [ -f "$change_guid" ]; then
|
||||
wlog "${KS} applying label to backup partition"
|
||||
sh $change_guid || report_post_failure_with_logfile "ERROR: Failed to update platform backup label and GUID"
|
||||
else
|
||||
wlog "${KS} /tmp/backup-guid-change.sh not found !!"
|
||||
fi
|
||||
|
||||
%end
|
||||
|
||||
%post --nochroot --erroronfail
|
||||
|
||||
# Source common functions
|
||||
. /tmp/ks-functions.sh
|
||||
KS="Prestaging post:"
|
||||
|
||||
error=false
|
||||
|
||||
@ -16,12 +48,12 @@ else
|
||||
fi
|
||||
wlog "${KS} install source : $SOURCE_DIR"
|
||||
|
||||
SW_VERSION=xxxPLATFORM_RELEASExxx
|
||||
STAGING_DIR="platform-backup"
|
||||
PRESTAGING_PART_LABEL=Platform\\x20Backup
|
||||
PRESTAGING_DEVICE=/dev/disk/by-partlabel/${PRESTAGING_PART_LABEL}
|
||||
PRESTAGING_REPO_DIR="${SOURCE_DIR}/opt/${STAGING_DIR}"
|
||||
PRESTAGING_LOCAL_DIR="/mnt/${STAGING_DIR}"
|
||||
export SW_VERSION=xxxPLATFORM_RELEASExxx
|
||||
export STAGING_DIR="platform-backup"
|
||||
export PRESTAGING_PART_LABEL=Platform\\x20Backup
|
||||
export PRESTAGING_DEVICE=/dev/disk/by-partlabel/${PRESTAGING_PART_LABEL}
|
||||
export PRESTAGING_REPO_DIR="${SOURCE_DIR}/opt/${STAGING_DIR}"
|
||||
export PRESTAGING_LOCAL_DIR="/mnt/${STAGING_DIR}"
|
||||
|
||||
wlog "${KS} SW_VERSION : ${SW_VERSION}"
|
||||
wlog "${KS} IMAGE_MOUNT : ${SOURCE_DIR}"
|
||||
@ -41,10 +73,37 @@ elif [ ! -d "${PRESTAGING_REPO_DIR}/${SW_VERSION}" ] ; then
|
||||
msg="repo ${PRESTAGING_REPO_DIR}/${SW_VERSION} sw version content missing"
|
||||
wlog "${KS} Prestaging Failed: ${msg}"
|
||||
report_prestaging_failure_with_msg "${msg}"
|
||||
elif [ ! -d "${PRESTAGING_LOCAL_DIR}" ] ; then
|
||||
fi
|
||||
|
||||
# Poll for the Platform Backup partition label.
|
||||
# TODO: Turn this into a function.
|
||||
found=false
|
||||
for i in {1..6} ; do
|
||||
|
||||
files=$(ls /dev/disk/by-partlabel)
|
||||
for file in $files ; do
|
||||
if [ "$file" == "Platform\x20Backup" ] ; then
|
||||
if [ ${i} -gt 1 ] ; then
|
||||
wlog "${KS} prestaging partition label found in ${i} audit"
|
||||
fi
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = true ] ; then
|
||||
break
|
||||
else
|
||||
wlog "${KS} searching for 'Platform\x20Backup' label ${i}"
|
||||
sleep 10
|
||||
fi
|
||||
done
|
||||
|
||||
# if the label is not visable yet then we will see it in a mount failure
|
||||
if [ ! -d "${PRESTAGING_LOCAL_DIR}" ] ; then
|
||||
wlog "${KS} mounting ${PRESTAGING_LOCAL_DIR}"
|
||||
mkdir -p ${PRESTAGING_LOCAL_DIR}
|
||||
mount ${PRESTAGING_DEVICE} ${PRESTAGING_LOCAL_DIR} 2>/dev/null
|
||||
mount ${PRESTAGING_DEVICE} ${PRESTAGING_LOCAL_DIR}
|
||||
rc=$?
|
||||
if [ $rc -eq 0 ] ; then
|
||||
sleep 2
|
||||
@ -66,26 +125,26 @@ if [ "$error" = true ] ; then
|
||||
report_prestaging_failure_with_msg "${msg}"
|
||||
fi
|
||||
|
||||
# create prestaging sw version dir if it does not already exist
|
||||
if [ ! -d ${PRESTAGING_LOCAL_DIR}/${SW_VERSION} ] ; then
|
||||
mkdir ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
||||
# nuke local prestaging dir - cleanup operation
|
||||
if [ -d ${PRESTAGING_LOCAL_DIR}/${SW_VERSION} ] ; then
|
||||
wlog "${KS} wiping prestaging dir '${PRESTAGING_LOCAL_DIR}/${SW_VERSION}'"
|
||||
rm -rf ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
||||
fi
|
||||
|
||||
# log the list of prestaged files
|
||||
check=$(md5sum ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}/*)
|
||||
wlog "${KS} ${PRESTAGING_LOCAL_DIR} files md5sums:"
|
||||
wlog "$check"
|
||||
# create local prestaging dir
|
||||
mkdir ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
||||
|
||||
# copy prestaging files to the local mount
|
||||
# enter the local prestaging dir for this release
|
||||
cd ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
||||
|
||||
# copy repo prestaging files to the local mount
|
||||
wlog "${KS} copy prestaging files"
|
||||
cp -a ${PRESTAGING_REPO_DIR}/${SW_VERSION} ${PRESTAGING_LOCAL_DIR}
|
||||
wlog "${KS} prestaging files copy done"
|
||||
|
||||
|
||||
# loop over all the prestaged files
|
||||
# - log files found
|
||||
# - do md5 check on md5 files found
|
||||
cd ${PRESTAGING_LOCAL_DIR}/${SW_VERSION}
|
||||
for file in * ; do
|
||||
filename="${file%.*}"
|
||||
extension="${file##*.}"
|
||||
@ -109,6 +168,8 @@ if [ "$error" = true ] ; then
|
||||
else
|
||||
wlog "${KS} prestaging integrity checks passed"
|
||||
fi
|
||||
wlog "${KS} prestaging complete"
|
||||
|
||||
wlog "${KS} prestaging complete"
|
||||
|
||||
%end
|
||||
|
@ -201,6 +201,7 @@ else
|
||||
cat<<EOF>/tmp/backup-guid-change.sh
|
||||
echo "\$(date '+%Y-%m-%d %H:%M:%S.%3N') - Updating backup partition GUID."
|
||||
flock $rootfs_device sgdisk --change-name=${BACKUP_PART_NO}:"${BACKUP_PART_LABEL}" --typecode=${BACKUP_PART_NO}:"${BACKUP_PART_GUID}" $rootfs_device || exit 1
|
||||
parted -l
|
||||
EOF
|
||||
|
||||
cat<<EOF>>/tmp/part-include
|
||||
|
Loading…
Reference in New Issue
Block a user