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: Ib7d1fdc8f91bc992ccf618ef6f57e99bb90c2dbc
Partial-Bug: #1770740
This commit is contained in:
Alex Kavanagh 2018-05-17 11:44:23 +01:00
parent 7ccf3569f7
commit 8b2303e863
1 changed files with 9 additions and 4 deletions

View File

@ -2248,14 +2248,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: