Move Upgrade branch change above initial library source

Upgrades fail on master due to changes to the library functions,
specifically "get_pip" which now requires a variable passed to it. Since
the library was sourced before it gets called in the Ocata branch this
caused failures when the function was called.

To fix this we should source the library after we change branches, and
not before. Additionally, we should source the scripts-library.sh from
master once we change back to the master branch.

Change-Id: If3fedfcf2dd5b13c918812fcb9aca7efea7d0f26
This commit is contained in:
Andy McCrae 2017-07-21 11:10:09 +01:00 committed by Andy McCrae
parent 7499771822
commit ece5067966

View File

@ -59,6 +59,20 @@ export ACTION=${2:-"deploy"}
# is created. The checkout must always be N-1.
export UPGRADE_SOURCE_BRANCH=${UPGRADE_SOURCE_BRANCH:-'stable/ocata'}
## Change branch for Upgrades ------------------------------------------------
# If the action is to upgrade, then store the current SHA,
# checkout the source SHA before executing the greenfield
# deployment.
# This needs to be done before the first "source" to ensure
# the correct functions are used for the branch.
if [[ "${ACTION}" == "upgrade" ]]; then
# Store the target SHA/branch
export UPGRADE_TARGET_BRANCH=$(git rev-parse HEAD)
# Now checkout the source SHA/branch
git checkout origin/${UPGRADE_SOURCE_BRANCH}
fi
## Functions -----------------------------------------------------------------
info_block "Checking for required libraries." 2> /dev/null || source "${OSA_CLONE_DIR}/scripts/scripts-library.sh"
@ -70,17 +84,6 @@ trap gate_job_exit_tasks EXIT
# Log some data about the instance and the rest of the system
log_instance_info
# If the action is to upgrade, then store the current SHA,
# checkout the source SHA before executing the greenfield
# deployment.
if [[ "${ACTION}" == "upgrade" ]]; then
# Store the target SHA/branch
export UPGRADE_TARGET_BRANCH=$(git rev-parse HEAD)
# Now checkout the source SHA/branch
git checkout origin/${UPGRADE_SOURCE_BRANCH}
fi
# Get minimum disk size
DATA_DISK_MIN_SIZE="$((1024**3 * $(awk '/bootstrap_host_data_disk_min_size/{print $2}' "${OSA_CLONE_DIR}/tests/roles/bootstrap-host/defaults/main.yml") ))"
@ -215,6 +218,9 @@ if [[ "${ACTION}" == "upgrade" ]]; then
unset ANSIBLE_PACKAGE
unset UPPER_CONSTRAINTS_FILE
# Source the current scripts-library.sh functions
source "${OSA_CLONE_DIR}/scripts/scripts-library.sh"
# Kick off the data plane tester
bash ${OSA_CLONE_DIR}/tests/data-plane-test.sh &> /var/log/data-plane-error.log &