Fix image validation when AP services get several images.

When AP (Actif/Passif) service get several images back from the host
the script is broken because it wrongly tests any left over image.

We fix that by sorting them by tag (the higher being at bottom of the
list) and taking only the last one.

We ensure as well that re-running the script doesn't unnecessarily
increase the number of hosts we test for AP services.

Change-Id: I24e05a15975fb5a696d195d87257bc7b7e1c561b
Related-Bug: #1843023
This commit is contained in:
Sofer Athlan-Guyot 2019-09-18 12:14:53 +02:00
parent e48c35a6ab
commit cece0f85d4
1 changed files with 2 additions and 1 deletions

View File

@ -53,6 +53,7 @@ for _ip in $( openstack server list -f value -c Networks | awk -F '=' '{ print $
# check if any of defined A/P services has image on a node
if [[ -n "${AP_SERVICES}" ]] ; then
rm -f {{ working_dir }}/AP_SERVICES_${_ap_service}.txt
for _ap_service in ${AP_SERVICES} ; do
CONTAINERS_PCMK_AP=$( ssh -q -o StrictHostKeyChecking=no \
{% if overcloud_ssh_user != '' %}{{overcloud_ssh_user}}{% else %}heat-admin{% endif %}@${_ip} \
@ -103,7 +104,7 @@ for _ap_service in ${AP_SERVICES} ; do
for _ip in $(cat AP_SERVICES_${_ap_service}.txt ) ; do
_image=$( ssh -q -o StrictHostKeyChecking=no \
{% if overcloud_ssh_user != '' %}{{overcloud_ssh_user}}{% else %}heat-admin{% endif %}@${_ip} \
"sudo podman images 2>&1" | awk '/'${_ap_service}'/ && !/pcmklatest/ { print $1":"$2}' )
"sudo podman images --sort tag 2>&1" | awk '/'${_ap_service}'/ && !/pcmklatest/ { print $1":"$2}' | tail -1 )
assert_image_in_file {{ working_dir }}/{{ container_registry_file }} ${_image}