From 09d6e9ffe41ad282e8abd064cc70d70b5ae7fb1c Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Mon, 11 Apr 2016 15:26:33 -0400 Subject: Fetching the current version a little more carefully Previously we were trying to use the running container to get the current version. There are cases in which the Master or Node may not be running during upgrade. It's actually safer to just run the container to fetch the version that would be launch if the container were running. Then we pull the image to see what the latest image contains. --- .../upgrades/files/openshift_container_versions.sh | 10 +++++----- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh b/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh index 7a1edf38f..96944a78b 100644 --- a/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh +++ b/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh @@ -3,19 +3,19 @@ # Here we don't really care if this is a master, api, controller or node image. # We just need to know the version of one of them. unit_file=$(ls /etc/systemd/system/${1}*.service | head -n1) -installed_container_name=$(basename -s .service ${unit_file}) -installed=$(docker exec ${installed_container_name} openshift version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') if [ ${1} == "origin" ]; then image_name="openshift/origin" elif grep aep $unit_file 2>&1 > /dev/null; then - image_name="aep3/aep" + image_name="aep3/node" elif grep openshift3 $unit_file 2>&1 > /dev/null; then - image_name="openshift3/ose" + image_name="openshift3/node" fi +installed=$(docker run --rm --entrypoint=/bin/openshift ${image_name} version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') + docker pull ${image_name} 2>&1 > /dev/null -available=$(docker run --rm ${image_name} version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') +available=$(docker run --rm --entrypoint=/bin/openshift ${image_name} version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') echo "---" echo "curr_version: ${installed}" diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index c1dabc150..21480ba55 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -149,6 +149,10 @@ g_new_version: "{{ openshift_image_tag | replace('v','') }}" when: openshift_image_tag is defined + - fail: + msg: Verifying the correct version was found + when: g_aos_versions.curr_version == "" + - fail: msg: Verifying the correct version was found when: verify_upgrade_version is defined and g_new_version != verify_upgrade_version -- cgit v1.2.3