From 46f41901d65429e1d13410276f530e82cd63033c Mon Sep 17 00:00:00 2001 From: Bin Qian Date: Thu, 10 Feb 2022 10:26:48 -0500 Subject: [PATCH] Do not install N+1 release unless upgrade in progress During upgrade, installer RPMs from release N need to be installed to host (release N+1). During downgrade, installer RPMs from release N+1 don't need to be installed to host (release N) Currently installer from "the other release" is installed to host regardless an upgrade is in progress or no by kickstarts. This requires the kickstarts on release N to understand the structure of installer RPM of future release. The installer from "the other release" only useful is when an upgrade is in progress (to provide installer when downgrade is required). This change removes the step to install RPMs from other release to host when upgrade is not in progress. TCs: Upgrade from 21.05 -> 21.12 abort after controller-1 upgrade completed Upgrade from 21.05 -> 21.12 Upgrade from 21.12 -> 22.02 abort after controller-1 upgrade completed Upgrade from 21.12 -> 22.02 load delete after 21.05 -> 21.12 upgrade abort load delete after 21.05 -> 21.12 upgrade complete load delete after 21.12 -> 22.02 upgrade abort load delete after 21.12 -> 22.02 upgrade complete Depends-on: https://review.opendev.org/c/starlingx/config/+/829943 Closes-bug: 1961424 Change-Id: I86edbe09410d3df9b9440d89208af90f0eb1fd09 Signed-off-by: Bin Qian --- bsp-files/kickstarts/post_net_controller.cfg | 82 ++++++++++---------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/bsp-files/kickstarts/post_net_controller.cfg b/bsp-files/kickstarts/post_net_controller.cfg index b1017207..fb42e439 100644 --- a/bsp-files/kickstarts/post_net_controller.cfg +++ b/bsp-files/kickstarts/post_net_controller.cfg @@ -34,47 +34,49 @@ echo "Done" >/dev/console shopt -s nullglob -# Check whether a second release is installed -. /etc/build.info -CURRENT_REL_DIR=rel-${SW_VERSION} -OTHER_REL_DIR= -for REL_DIR in /var/www/pages/feed/*; do - if [[ ! $REL_DIR =~ "${SW_VERSION}" ]]; then - OTHER_REL_DIR=`basename $REL_DIR` - OTHER_REL_VERSION=${OTHER_REL_DIR:4} - break +if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/upgrade_in_progress 2>/dev/null)" = "true" ]; then + # Check whether a second release is installed + . /etc/build.info + CURRENT_REL_DIR=rel-${SW_VERSION} + OTHER_REL_DIR= + for REL_DIR in /var/www/pages/feed/*; do + if [[ ! $REL_DIR =~ "${SW_VERSION}" ]]; then + OTHER_REL_DIR=`basename $REL_DIR` + OTHER_REL_VERSION=${OTHER_REL_DIR:4} + break + fi + done + + # If second release is installed, find the latest version of the installer + # RPM and install the pxeboot files we require to boot hosts with that release. + if [ ! -z "$OTHER_REL_DIR" ]; then + PATCH_RPM=`find /var/www/pages/updates/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1` + BASE_RPM=`find /var/www/pages/feed/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1` + + if [ ! -z "$PATCH_RPM" ]; then + INSTALL_RPM=$PATCH_RPM + elif [ ! -z "$BASE_RPM" ]; then + INSTALL_RPM=$BASE_RPM + else + report_post_failure_with_msg "ERROR: Unable to find pxe-network-installer RPM for $OTHER_REL_DIR. Aborting installation." + fi + + echo "Installing pxeboot files for release $OTHER_REL_DIR from $INSTALL_RPM" >/dev/console + TMP_RPM=/tmp/pxe-network-installer + mkdir $TMP_RPM + pushd $TMP_RPM + /usr/bin/rpm2cpio $INSTALL_RPM | cpio -idm \ + || report_post_failure_with_msg "Failed to extract pxe-network-installer" + + cp -r $TMP_RPM/usr / \ + || report_post_failure_with_msg "Failed to copy pxe-network-installer /usr" + cp -r $TMP_RPM/pxeboot/$OTHER_REL_DIR /var/pxeboot/ \ + || report_post_failure_with_msg "Failed to copy pxe-network-installer /var/pxeboot/$OTHER_REL_DIR" + cp $TMP_RPM/pxeboot/pxelinux.cfg.files/*-$OTHER_REL_VERSION /var/pxeboot/pxelinux.cfg.files/ \ + || report_post_failure_with_msg "Failed to copy pxe-network-installer pxelinux.cfg files" + + rm -rf $TMP_RPM fi -done - -# If second release is installed, find the latest version of the installer -# RPM and install the pxeboot files we require to boot hosts with that release. -if [ ! -z "$OTHER_REL_DIR" ]; then - PATCH_RPM=`find /var/www/pages/updates/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1` - BASE_RPM=`find /var/www/pages/feed/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1` - - if [ ! -z "$PATCH_RPM" ]; then - INSTALL_RPM=$PATCH_RPM - elif [ ! -z "$BASE_RPM" ]; then - INSTALL_RPM=$BASE_RPM - else - report_post_failure_with_msg "ERROR: Unable to find pxe-network-installer RPM for $OTHER_REL_DIR. Aborting installation." - fi - - echo "Installing pxeboot files for release $OTHER_REL_DIR from $INSTALL_RPM" >/dev/console - TMP_RPM=/tmp/pxe-network-installer - mkdir $TMP_RPM - pushd $TMP_RPM - /usr/bin/rpm2cpio $INSTALL_RPM | cpio -idm \ - || report_post_failure_with_msg "Failed to extract pxe-network-installer" - - cp -r $TMP_RPM/usr / \ - || report_post_failure_with_msg "Failed to copy pxe-network-installer /usr" - cp -r $TMP_RPM/pxeboot/$OTHER_REL_DIR /var/pxeboot/ \ - || report_post_failure_with_msg "Failed to copy pxe-network-installer /var/pxeboot/$OTHER_REL_DIR" - cp $TMP_RPM/pxeboot/pxelinux.cfg.files/*-$OTHER_REL_VERSION /var/pxeboot/pxelinux.cfg.files/ \ - || report_post_failure_with_msg "Failed to copy pxe-network-installer pxelinux.cfg files" - - rm -rf $TMP_RPM fi %end