Improve openstack-release file discovery

In cases where the deployment node is seperated from the infrastructure
node, the openstack-release file discovery logic might calculate the
wrong release since the /etc/openstack-release file does not get generated
on the deployment node.
This commit adds logic to pull down the /etc/openstack-release file from
the infrastucture node to the deployment node. This way, the release discovery
logic will properly assess the openstack release even in situations where the
deployment node is isolated from the infra node.
If the openstack-release file is not found, an attempt to retrieve the
rpc-release file is made.

A conditional is added to check if the rpc-release file exist in the
environment. If it does, and there is no openstack-release file, then
the deployment version is set to Juno.

Co-Authored-By: git-harry <git-harry@live.co.uk>

Change-Id: I6136609ef11be7b98ddcfc7589dd17cf1e98c362
This commit is contained in:
Miguel Alex Cantu 2017-07-11 10:43:22 -05:00 committed by git-harry
parent 8a182302ee
commit ebb827ea46

View File

@ -151,7 +151,16 @@ function validate_upgrade_input {
}
function discover_code_version {
if [[ ! -f "/etc/openstack-release" ]]; then
# If there is no release file present, then try to find one
# from the infra node.
if [[ ! -f "/etc/openstack-release" && ! -f "/etc/rpc-release" ]]; then
get_openstack_release_file
fi
if [[ ! -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
export CODE_UPGRADE_FROM="JUNO"
notice "You seem to be running Juno"
else
@ -177,6 +186,34 @@ function discover_code_version {
fi
}
function get_openstack_release_file {
notice "Getting openstack release file from infra1 if it exists"
# Get openstack_user_config.yml file path
USER_CONFIG_FILE=$(find /etc/ -name '*_user_config.yml' -o -name 'os-infra_hosts.yml')
# Get IP of os_infra node
INFRA_IP=$(sed -n -e '/infra_hosts/, /ip:/ p' ${USER_CONFIG_FILE} | awk '/ip:/ {print $2; exit}')
if [[ -z "${INFRA_IP}" ]]; then
failure "Could not find infra ip to get openstack-release file. Exiting.."
exit 99
fi
# Get the release file from the infra node.
set +e
errmsg=$(scp -o StrictHostKeyChecking=no root@${INFRA_IP}:/etc/openstack-release /etc/openstack-release 2>&1)
if [[ $? -ne 0 ]]; then
if echo "${errmsg}" | grep -v 'scp: /etc/openstack-release: No such file or directory'; then
failure "Fetching '/etc/openstack-release' failed with the error '${errmsg}'"
exit 99
fi
notice "An error occurred trying to scp the /etc/openstack-release file from the infra node, checking for /etc/rpc-release..."
scp -o StrictHostKeyChecking=no root@${INFRA_IP}:/etc/rpc-release /etc/rpc-release
if [[ $? -ne 0 ]]; then
notice "An error occurred trying to scp the /etc/rpc-release file from the infra node. Could not find release file. Exiting."
exit 99
fi
fi
set -e
}
function set_upgrade_vars {
notice "Setting up vars for the LEAP"
case "${CODE_UPGRADE_FROM}" in