Fix Traceback issue when ceph-osd upgrade fails

Bug/1770740 surfaced an issue where get_upgrade_position() returns None
but the calling function expects and exception to the thrown if the
"None" condition exists.  This just fixes the code so that the Traceback
is stopped and the appropriate error/message is logged for the
condition.

Change-Id: I16539b2bc35104eed54033bebb1154cad8a5cf0f
Partial-Bug: #1770740
This commit is contained in:
Alex Kavanagh 2019-11-20 10:22:23 +00:00
parent 3b6a74bea0
commit 1512de6472
1 changed files with 9 additions and 4 deletions

View File

@ -2310,14 +2310,19 @@ def wait_on_previous_node(upgrade_key, service, previous_node, version):
def get_upgrade_position(osd_sorted_list, match_name):
"""Return the upgrade position for the given osd.
:param osd_sorted_list: list. Osds sorted
:param match_name: str. The osd name to match
:returns: int. The position or None if not found
:param osd_sorted_list: Osds sorted
:type osd_sorted_list: [str]
:param match_name: The osd name to match
:type match_name: str
:returns: The position of the name
:rtype: int
:raises: ValueError if name is not found
"""
for index, item in enumerate(osd_sorted_list):
if item.name == match_name:
return index
return None
raise ValueError("osd name '{}' not found in get_upgrade_position list"
.format(match_name))
# Edge cases: