From 6c101e313c2c613bc91baf91cd707d5404feae21 Mon Sep 17 00:00:00 2001 From: Antony Messerli Date: Tue, 11 Dec 2018 11:32:23 -0600 Subject: [PATCH] Better handling for resuming leapfrog upgrade Copies the openstack-release file to another location so that the original version being upgraded can be referenced in the event of a failure where openstack-setup-hosts has replaced the openstack-release file. That way the list of versions to upgrade is correct upon re-running the leapfrog upgrade script. Change-Id: I63de16bf27813dd623e996a5ac5de7bb8f8668b6 --- leap-upgrades/lib/functions.sh | 54 ++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/leap-upgrades/lib/functions.sh b/leap-upgrades/lib/functions.sh index f2d7dd04..c35f1fbc 100644 --- a/leap-upgrades/lib/functions.sh +++ b/leap-upgrades/lib/functions.sh @@ -197,7 +197,12 @@ function discover_code_version { get_openstack_release_file fi - if [[ ! -f "/etc/openstack-release" && ! -f "/etc/rpc-release" ]]; then + if [[ -f "/opt/leap42/openstack-release.leap" ]]; then + # if openstack-release.leap is found, then it is the source + # of truth for the original release being upgraded from + source /opt/leap42/openstack-release.leap + determine_openstack_release + elif [[ ! -f "/etc/openstack-release" && ! -f "/etc/rpc-release" ]]; then failure "No release file could be found." exit 99 elif [[ ! -f "/etc/openstack-release" && -f "/etc/rpc-release" ]]; then @@ -205,27 +210,31 @@ function discover_code_version { notice "You seem to be running Juno" else source /etc/openstack-release - case "${DISTRIB_RELEASE%%.*}" in - *11|eol-kilo) - export CODE_UPGRADE_FROM="KILO" - notice "You seem to be running Kilo" - ;; - *12|liberty-eol) - export CODE_UPGRADE_FROM="LIBERTY" - notice "You seem to be running Liberty" - ;; - *13|mitaka-eol) - export CODE_UPGRADE_FROM="MITAKA" - notice "You seem to be running Mitaka" - ;; - *14|newton-eol) - export CODE_UPGRADE_FROM="NEWTON" - notice "You seem to be running Newton" - ;; - esac + determine_openstack_release fi } +function determine_openstack_release { + case "${DISTRIB_RELEASE%%.*}" in + *11|eol-kilo) + export CODE_UPGRADE_FROM="KILO" + notice "You seem to be running Kilo" + ;; + *12|liberty-eol) + export CODE_UPGRADE_FROM="LIBERTY" + notice "You seem to be running Liberty" + ;; + *13|mitaka-eol) + export CODE_UPGRADE_FROM="MITAKA" + notice "You seem to be running Mitaka" + ;; + *14|newton-eol) + export CODE_UPGRADE_FROM="NEWTON" + notice "You seem to be running Newton" + ;; + esac +} + function get_openstack_release_file { notice "Getting openstack release file from infra1 if it exists" # Get openstack_user_config.yml file path @@ -339,6 +348,13 @@ function pre_flight { mkdir -p /opt/leap42/venvs + # Make a copy of the original origin release so that we know what the + # original version was in case it's overwritten later on so that we can + # resume from the proper release + if [[ ! -f "/opt/leap42/openstack-release.leap" ]]; then + cp /etc/openstack-release /opt/leap42/openstack-release.leap + fi + # If the lxc backend store was not set halt and instruct the user to set it. In Juno we did more to detect the backend storage # size than we do in later releases. While the auto-detection should still work it's best to have the deployer set the value # desired before moving forward.