From e7ea3b56c6d52462b77178a71c1c84fa5e3d2c9b Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 11 Oct 2017 01:19:44 -0500 Subject: [PATCH] Add option to set FROM code and fix logic bug The leap tooling was attempting to run `set_upgrade_vars` at point where specific upgrade variables were already needed. Within this change that function call is moved up a few lines so that it has the chance to set the required values. Additionally the option to pre-define the variable CODE_UPGRADE_FROM has been added giving the deployer the option to set this variable before a leap upgrade is run. Change-Id: I2c780eb46dd57e680fc8681824de2fe913824fd9 Signed-off-by: Kevin Carter --- leap-upgrades/lib/functions.sh | 18 +++++++++--------- leap-upgrades/lib/vars.sh | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/leap-upgrades/lib/functions.sh b/leap-upgrades/lib/functions.sh index b40804e7..0b886b56 100644 --- a/leap-upgrades/lib/functions.sh +++ b/leap-upgrades/lib/functions.sh @@ -274,6 +274,11 @@ function set_upgrade_vars { export ANSIBLE_INVENTORY="/opt/leap42/openstack-ansible-${RELEASE}/playbooks/inventory" export CONFIG_DIR="/etc/openstack_deploy" ;; + *) + warning "The option CODE_UPGRADE_FROM is set to \"${CODE_UPGRADE_FROM}\"" + failure "No CODE_UPGRADE_FROM match found. Please set CODE_UPGRADE_FROM before continuing." + exit 99 + ;; esac # Do not forget to export the TODOLIST if you run the scripts one by one. warning "export UPGRADES_TO_TODOLIST=\"${UPGRADES_TO_TODOLIST}\"" @@ -302,13 +307,10 @@ function pre_flight { fi fi - discover_code_version - - # set config directory here since we need to check if existing redeploy - # has been kicked off before prompting for the release, JUNO is the only - # other directory that may differ but since we aren't leaping to JUNO, - # this should be safe to set here - CONFIG_DIR="/etc/openstack_deploy" + if [[ ! -n "${CODE_UPGRADE_FROM}" ]]; then + discover_code_version + fi + set_upgrade_vars if [[ -f "${CONFIG_DIR}/upgrade-leap/redeploy-started.complete" && ! -f "${CONFIG_DIR}/upgrade-leap/osa-leap.complete" ]]; then resume_incomplete_leap @@ -316,8 +318,6 @@ function pre_flight { validate_upgrade_input fi - set_upgrade_vars - mkdir -p /opt/leap42/venvs # 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 diff --git a/leap-upgrades/lib/vars.sh b/leap-upgrades/lib/vars.sh index a12b0344..a8fa2ee9 100644 --- a/leap-upgrades/lib/vars.sh +++ b/leap-upgrades/lib/vars.sh @@ -40,7 +40,7 @@ export UPGRADE_UTILS="${UPGRADE_UTILS:-${SYSTEM_PATH}/upgrade-utilities}" export VENV_URL="${VENV_URL:-https://rpc-repo.rackspace.com/venvs/leap-bundles}" export VALIDATE_UPGRADE_INPUT="${VALIDATE_UPGRADE_INPUT:-TRUE}" -export CODE_UPGRADE_FROM="" +export CODE_UPGRADE_FROM="${CODE_UPGRADE_FROM:-}" # Bootstrap ansible tool, see also bootstrap_recent_ansible export BOOTSTRAP_ANSIBLE_FOLDER=${BOOTSTRAP_ANSIBLE_FOLDER:-/opt/openstack-ansible/}