Re-fix Traceback issue when ceph-osd upgrade fails

This was originally fixed in Ib7d1fdc8f91bc992ccf618ef6f57e99bb90c2dbc
but unfortunately wasn't also added to the charms.ceph library.  Thus,
this is a re-application of that fix; the charms to ceph fix is in [1].

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.

[1] https://review.opendev.org/#/c/695163/
    I16539b2bc35104eed54033bebb1154cad8a5cf0f

Change-Id: Ieee8d13f25027ad540a23a6428c2226b6c20999a
Partial-Bug: #1770740
This commit is contained in:
Alex Kavanagh 2019-11-20 10:26:28 +00:00
parent 67254e334f
commit b15a23ef6a
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: