From c68ed4dd516e37844a3eb9cdd2089c985173571d Mon Sep 17 00:00:00 2001
From: Mariusz <mariusz.karpiarz@vscaler.com>
Date: Fri, 28 Jun 2019 13:33:39 +0000
Subject: [PATCH] Handle more return codes from nova-status upgrade check

In a single controller scenario, the "Upgrade status check result"
does nothing because the previous task can only succeed when
`nova-status upgrade check` returns code 0. This change allows this
command to fail, so that the value of returned code stored in
`nova_upgrade_check_stdout` can then be analysed.

This change also allows for warnings (rc 1) to pass.
Closes-Bug: 1834647

Change-Id: I6f5e37832f43f23604920b9d890cc505ca924ff9
---
 ansible/roles/nova/tasks/upgrade.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ansible/roles/nova/tasks/upgrade.yml b/ansible/roles/nova/tasks/upgrade.yml
index 1433394d38..f33f11fae8 100644
--- a/ansible/roles/nova/tasks/upgrade.yml
+++ b/ansible/roles/nova/tasks/upgrade.yml
@@ -4,15 +4,16 @@
   command: docker exec -t nova_api nova-status upgrade check
   register: nova_upgrade_check_stdout
   when: inventory_hostname == groups['nova-api'][0]
+  failed_when: false
 
 - name: Upgrade status check result
   fail:
     msg:
-      - "There was an upgrade status check warning or failure!"
+      - "There was an upgrade status check failure!"
       - "See the detail at https://docs.openstack.org/nova/latest/cli/nova-status.html#nova-status-checks"
   vars:
     first_nova_api_host: "{{ groups['nova-api'][0] }}"
-  when: hostvars[first_nova_api_host]['nova_upgrade_check_stdout']['rc'] != 0
+  when: hostvars[first_nova_api_host]['nova_upgrade_check_stdout']['rc'] not in [0, 1]
 
 - include_tasks: legacy_upgrade.yml
   when: not nova_enable_rolling_upgrade | bool