From ebb827ea46d071cbbba15bc0a6572bd60032cfb0 Mon Sep 17 00:00:00 2001 From: Miguel Alex Cantu Date: Tue, 11 Jul 2017 10:43:22 -0500 Subject: [PATCH] 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 Change-Id: I6136609ef11be7b98ddcfc7589dd17cf1e98c362 --- leap-upgrades/lib/functions.sh | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/leap-upgrades/lib/functions.sh b/leap-upgrades/lib/functions.sh index 8e91894a..634b410e 100644 --- a/leap-upgrades/lib/functions.sh +++ b/leap-upgrades/lib/functions.sh @@ -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