From b8d3218d1e40d3593d022d66ad3d91ccf01adf85 Mon Sep 17 00:00:00 2001 From: Yariv Rachmani Date: Sun, 8 Nov 2020 17:37:04 +0200 Subject: [PATCH] [FFWD] Propose a fix for node_upgrade_pre.sh.j2 If overcloud already exist and migration needed before compute upgrade Which means workload_launch=false and compute_present=true compute_upgrade_pre.sh is not created. This fix allows the above parameter mix to create and run compute_upgrade_pre.sh Adding condition check in compute_upgrade_pre.sh 1) If no active computes on host, live migration will not occur 2) Adding --all param to see tenant vms on compute Change-Id: I3cd33592a625cb8d8dabd0ad09e5f95e1e3be556 --- .../create-overcloud-ffu-hosts-scripts.yaml | 4 +--- .../overcloud_upgrade_hosts.yaml | 4 +--- templates/node_upgrade_pre.sh.j2 | 12 +++++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tasks/fast-forward-upgrade/create-overcloud-ffu-hosts-scripts.yaml b/tasks/fast-forward-upgrade/create-overcloud-ffu-hosts-scripts.yaml index e407971b..5eef37bb 100644 --- a/tasks/fast-forward-upgrade/create-overcloud-ffu-hosts-scripts.yaml +++ b/tasks/fast-forward-upgrade/create-overcloud-ffu-hosts-scripts.yaml @@ -4,9 +4,7 @@ when: pcs_present - name: create compute pre upgrade script for {{ item }} - when: - - compute_present|bool - - workload_launch|bool + when: (compute_present | bool) or (workload_launch | bool) vars: node_name: "{{ item | reject('none') | join(',') }}" template: diff --git a/tasks/fast-forward-upgrade/overcloud_upgrade_hosts.yaml b/tasks/fast-forward-upgrade/overcloud_upgrade_hosts.yaml index 20eda7dc..574b0124 100644 --- a/tasks/fast-forward-upgrade/overcloud_upgrade_hosts.yaml +++ b/tasks/fast-forward-upgrade/overcloud_upgrade_hosts.yaml @@ -12,9 +12,7 @@ tags: ffu_overcloud_system_upgrade - name: run the pre upgrade script for the host {{ host }} - when: - - compute_present|bool - - workload_launch|bool + when: (compute_present | bool) or (workload_launch | bool) shell: | set -o pipefail ./{{ host }}_upgrade_pre.sh 2>&1 {{ timestamper_cmd }} >> {{ host }}_upgrade_pre.log diff --git a/templates/node_upgrade_pre.sh.j2 b/templates/node_upgrade_pre.sh.j2 index a5700367..02b060ca 100644 --- a/templates/node_upgrade_pre.sh.j2 +++ b/templates/node_upgrade_pre.sh.j2 @@ -2,13 +2,19 @@ source {{ overcloud_rc }} ## Get exact hostname HOST=$(openstack compute service list -f value -c Host | grep {{ node_name }} ) -nova host-evacuate-live ${HOST} +INSTANCE_COUNT=$(openstack server list --all --host ${HOST} -f json | jq -r -c '[.[] | select(.Status | contains("ACTIVE"))] | length') + +if [ $INSTANCE_COUNT != 0 ]; then + nova host-evacuate-live ${HOST} +else + echo "No vms in active state on ${HOST}" +fi timeout_seconds=120 elapsed_seconds=0 -while true; do +while [ $INSTANCE_COUNT != 0 ]; do echo "Waiting for ${HOST} to get quiesced ..." - INSTANCE_COUNT=$(openstack server list --host ${HOST} -f json | jq -r -c '[.[] | select(.Status | contains("ACTIVE") or contains("PAUSED") or contains("MIGRATING"))] | length') + INSTANCE_COUNT=$(openstack server list --all --host ${HOST} -f json | jq -r -c '[.[] | select(.Status | contains("ACTIVE") or contains("PAUSED") or contains("MIGRATING"))] | length') if [ $INSTANCE_COUNT == 0 ]; then break fi