summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-01-10 09:28:58 +0000
committerGerrit Code Review <review@openstack.org>2018-01-10 09:28:59 +0000
commit8d10c2026e650728c39d6cb4c8ab518c80121154 (patch)
treefe9de00cf59982cb208cac6eb7ee34e438c2ffe7
parentdd2f3db1f459d69f989904e0963f8439e3907037 (diff)
parente007b5265cd30baccb44adb4c2471fe9d6b8db78 (diff)
Merge "py3: Deal with comparison with str and None"
-rw-r--r--ceph/utils.py41
-rw-r--r--unit_tests/test_mon_upgrade_roll.py7
2 files changed, 27 insertions, 21 deletions
diff --git a/ceph/utils.py b/ceph/utils.py
index a6e827a..0f9d23a 100644
--- a/ceph/utils.py
+++ b/ceph/utils.py
@@ -1805,25 +1805,28 @@ def wait_on_previous_node(upgrade_key, service, previous_node, version):
1805 previous_node_start_time = monitor_key_get( 1805 previous_node_start_time = monitor_key_get(
1806 upgrade_key, 1806 upgrade_key,
1807 "{}_{}_{}_start".format(service, previous_node, version)) 1807 "{}_{}_{}_start".format(service, previous_node, version))
1808 if (current_timestamp - (10 * 60)) > previous_node_start_time: 1808 if (previous_node_start_time is not None and
1809 # Previous node is probably dead. Lets move on 1809 ((current_timestamp - (10 * 60)) >
1810 if previous_node_start_time is not None: 1810 float(previous_node_start_time))):
1811 log( 1811 # NOTE(jamespage):
1812 "Waited 10 mins on node {}. current time: {} > " 1812 # Previous node is probably dead as we've been waiting
1813 "previous node start time: {} Moving on".format( 1813 # for 10 minutes - lets move on and upgrade
1814 previous_node, 1814 log("Waited 10 mins on node {}. current time: {} > "
1815 (current_timestamp - (10 * 60)), 1815 "previous node start time: {} Moving on".format(
1816 previous_node_start_time)) 1816 previous_node,
1817 return 1817 (current_timestamp - (10 * 60)),
1818 else: 1818 previous_node_start_time))
1819 # I have to wait. Sleep a random amount of time and then 1819 return
1820 # check if I can lock,upgrade and roll. 1820 # NOTE(jamespage)
1821 wait_time = random.randrange(5, 30) 1821 # Previous node has not started, or started less than
1822 log('waiting for {} seconds'.format(wait_time)) 1822 # 10 minutes ago - sleep a random amount of time and
1823 time.sleep(wait_time) 1823 # then check again.
1824 previous_node_finished = monitor_key_exists( 1824 wait_time = random.randrange(5, 30)
1825 upgrade_key, 1825 log('waiting for {} seconds'.format(wait_time))
1826 "{}_{}_{}_done".format(service, previous_node, version)) 1826 time.sleep(wait_time)
1827 previous_node_finished = monitor_key_exists(
1828 upgrade_key,
1829 "{}_{}_{}_done".format(service, previous_node, version))
1827 1830
1828 1831
1829def get_upgrade_position(osd_sorted_list, match_name): 1832def get_upgrade_position(osd_sorted_list, match_name):
diff --git a/unit_tests/test_mon_upgrade_roll.py b/unit_tests/test_mon_upgrade_roll.py
index f1ac310..6a763ba 100644
--- a/unit_tests/test_mon_upgrade_roll.py
+++ b/unit_tests/test_mon_upgrade_roll.py
@@ -46,7 +46,10 @@ def monitor_key_side_effect(*args):
46 elif args[1] == \ 46 elif args[1] == \
47 'mon_ip-192-168-1-2_0.94.1_start': 47 'mon_ip-192-168-1-2_0.94.1_start':
48 # Return that the previous node started 9 minutes ago 48 # Return that the previous node started 9 minutes ago
49 return previous_node_start_time 49 # NOTE(jamespage):
50 # Pass back as string as this is what we actually get
51 # from the monitor cluster
52 return str(previous_node_start_time)
50 53
51 54
52class UpgradeRollingTestCase(unittest.TestCase): 55class UpgradeRollingTestCase(unittest.TestCase):
@@ -292,4 +295,4 @@ class UpgradeRollingTestCase(unittest.TestCase):
292 [call('Previous node is: ip-192-168-1-2')], 295 [call('Previous node is: ip-192-168-1-2')],
293 [call('ip-192-168-1-2 is not finished. Waiting')], 296 [call('ip-192-168-1-2 is not finished. Waiting')],
294 ) 297 )
295 self.assertEqual(tval[0], previous_node_start_time + 700) 298 self.assertGreaterEqual(tval[0], previous_node_start_time + 600)