Merge "py3: Deal with comparison with str and None"

This commit is contained in:
Zuul 2018-01-10 09:28:58 +00:00 committed by Gerrit Code Review
commit 8d10c2026e
2 changed files with 27 additions and 21 deletions

View File

@ -1805,25 +1805,28 @@ def wait_on_previous_node(upgrade_key, service, previous_node, version):
previous_node_start_time = monitor_key_get( previous_node_start_time = monitor_key_get(
upgrade_key, upgrade_key,
"{}_{}_{}_start".format(service, previous_node, version)) "{}_{}_{}_start".format(service, previous_node, version))
if (current_timestamp - (10 * 60)) > previous_node_start_time: if (previous_node_start_time is not None and
# Previous node is probably dead. Lets move on ((current_timestamp - (10 * 60)) >
if previous_node_start_time is not None: float(previous_node_start_time))):
log( # NOTE(jamespage):
"Waited 10 mins on node {}. current time: {} > " # Previous node is probably dead as we've been waiting
"previous node start time: {} Moving on".format( # for 10 minutes - lets move on and upgrade
previous_node, log("Waited 10 mins on node {}. current time: {} > "
(current_timestamp - (10 * 60)), "previous node start time: {} Moving on".format(
previous_node_start_time)) previous_node,
return (current_timestamp - (10 * 60)),
else: previous_node_start_time))
# I have to wait. Sleep a random amount of time and then return
# check if I can lock,upgrade and roll. # NOTE(jamespage)
wait_time = random.randrange(5, 30) # Previous node has not started, or started less than
log('waiting for {} seconds'.format(wait_time)) # 10 minutes ago - sleep a random amount of time and
time.sleep(wait_time) # then check again.
previous_node_finished = monitor_key_exists( wait_time = random.randrange(5, 30)
upgrade_key, log('waiting for {} seconds'.format(wait_time))
"{}_{}_{}_done".format(service, previous_node, version)) time.sleep(wait_time)
previous_node_finished = monitor_key_exists(
upgrade_key,
"{}_{}_{}_done".format(service, previous_node, version))
def get_upgrade_position(osd_sorted_list, match_name): def get_upgrade_position(osd_sorted_list, match_name):

View File

@ -46,7 +46,10 @@ def monitor_key_side_effect(*args):
elif args[1] == \ elif args[1] == \
'mon_ip-192-168-1-2_0.94.1_start': 'mon_ip-192-168-1-2_0.94.1_start':
# Return that the previous node started 9 minutes ago # Return that the previous node started 9 minutes ago
return previous_node_start_time # NOTE(jamespage):
# Pass back as string as this is what we actually get
# from the monitor cluster
return str(previous_node_start_time)
class UpgradeRollingTestCase(unittest.TestCase): class UpgradeRollingTestCase(unittest.TestCase):
@ -292,4 +295,4 @@ class UpgradeRollingTestCase(unittest.TestCase):
[call('Previous node is: ip-192-168-1-2')], [call('Previous node is: ip-192-168-1-2')],
[call('ip-192-168-1-2 is not finished. Waiting')], [call('ip-192-168-1-2 is not finished. Waiting')],
) )
self.assertEqual(tval[0], previous_node_start_time + 700) self.assertGreaterEqual(tval[0], previous_node_start_time + 600)