From 16e5db982c04118584e25617e6d22343e10454ec Mon Sep 17 00:00:00 2001 From: Antony Messerli Date: Tue, 12 Sep 2017 10:17:35 -0500 Subject: [PATCH] Adjust logic to allow for redeploy retry on failure Previously if a redeploy failed during the process, if you attempted to start it over, it would reprompt for the version you were attempting to upgrade. At this point in process, you are already on the latest version of the code, so putting the original code version would actually break the leap. This attempts to detect if a redeploy started but didn't complete and asks the user if they would like to reattempt the redeploy. Change-Id: I7c2f734edc4ec3186be3d24a60ee41b43269d07b --- leap-upgrades/lib/functions.sh | 15 ++++++++++++++- leap-upgrades/re-deploy.sh | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/leap-upgrades/lib/functions.sh b/leap-upgrades/lib/functions.sh index 4c042c57..f0b56460 100644 --- a/leap-upgrades/lib/functions.sh +++ b/leap-upgrades/lib/functions.sh @@ -131,6 +131,17 @@ function bootstrap_recent_ansible { popd } +function resume_incomplete_leap { + echo + notice "Detected previous leap attempt to ${CODE_UPGRADE_FROM}." + notice 'Would you like to reattempt this leap upgrade?' + read -p 'Enter "YES" to continue:' RUSURE + if [[ "${RUSURE}" != "YES" ]]; then + notice "Quitting..." + exit 99 + fi +} + function validate_upgrade_input { echo @@ -278,7 +289,9 @@ function pre_flight { discover_code_version - if [ "${VALIDATE_UPGRADE_INPUT}" == "TRUE" ]; then + if [[ -f "${CONFIG_DIR}/upgrade-leap/redeploy-started.complete" && ! -f "${CONFIG_DIR}/upgrade-leap/osa-leap.complete" ]]; then + resume_incomplete_leap + elif [ "${VALIDATE_UPGRADE_INPUT}" == "TRUE" ]; then validate_upgrade_input fi diff --git a/leap-upgrades/re-deploy.sh b/leap-upgrades/re-deploy.sh index 192a5e06..29bccd66 100755 --- a/leap-upgrades/re-deploy.sh +++ b/leap-upgrades/re-deploy.sh @@ -21,6 +21,12 @@ set -e -u source lib/vars.sh source lib/functions.sh +### Set lock file to notate redeploy has started +# Notate that redeploy has started, if it fails midway, it can be +# resumed from the starting script without getting prompted to +# set the version again. +touch /etc/openstack_deploy/upgrade-leap/redeploy-started.complete + ### Run the redeploy tasks # Forget about the old neutron agent container in inventory. # This is done to maximize uptime by leaving the old systems in