Browse Source

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

changes/85/532485/1
Zuul 1 year ago
parent
commit
8d10c2026e
2 changed files with 27 additions and 21 deletions
  1. 22
    19
      ceph/utils.py
  2. 5
    2
      unit_tests/test_mon_upgrade_roll.py

+ 22
- 19
ceph/utils.py View File

@@ -1805,25 +1805,28 @@ def wait_on_previous_node(upgrade_key, service, previous_node, version):
1805 1805
         previous_node_start_time = monitor_key_get(
1806 1806
             upgrade_key,
1807 1807
             "{}_{}_{}_start".format(service, previous_node, version))
1808
-        if (current_timestamp - (10 * 60)) > previous_node_start_time:
1809
-            # Previous node is probably dead. Lets move on
1810
-            if previous_node_start_time is not None:
1811
-                log(
1812
-                    "Waited 10 mins on node {}. current time: {} > "
1813
-                    "previous node start time: {} Moving on".format(
1814
-                        previous_node,
1815
-                        (current_timestamp - (10 * 60)),
1816
-                        previous_node_start_time))
1817
-                return
1818
-        else:
1819
-            # I have to wait. Sleep a random amount of time and then
1820
-            # check if I can lock,upgrade and roll.
1821
-            wait_time = random.randrange(5, 30)
1822
-            log('waiting for {} seconds'.format(wait_time))
1823
-            time.sleep(wait_time)
1824
-            previous_node_finished = monitor_key_exists(
1825
-                upgrade_key,
1826
-                "{}_{}_{}_done".format(service, previous_node, version))
1808
+        if (previous_node_start_time is not None and
1809
+                ((current_timestamp - (10 * 60)) >
1810
+                 float(previous_node_start_time))):
1811
+            # NOTE(jamespage):
1812
+            # Previous node is probably dead as we've been waiting
1813
+            # for 10 minutes - lets move on and upgrade
1814
+            log("Waited 10 mins on node {}. current time: {} > "
1815
+                "previous node start time: {} Moving on".format(
1816
+                    previous_node,
1817
+                    (current_timestamp - (10 * 60)),
1818
+                    previous_node_start_time))
1819
+            return
1820
+        # NOTE(jamespage)
1821
+        # Previous node has not started, or started less than
1822
+        # 10 minutes ago - sleep a random amount of time and
1823
+        # then check again.
1824
+        wait_time = random.randrange(5, 30)
1825
+        log('waiting for {} seconds'.format(wait_time))
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
 
1829 1832
 def get_upgrade_position(osd_sorted_list, match_name):

+ 5
- 2
unit_tests/test_mon_upgrade_roll.py View File

@@ -46,7 +46,10 @@ def monitor_key_side_effect(*args):
46 46
     elif args[1] == \
47 47
             'mon_ip-192-168-1-2_0.94.1_start':
48 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
 
52 55
 class UpgradeRollingTestCase(unittest.TestCase):
@@ -292,4 +295,4 @@ class UpgradeRollingTestCase(unittest.TestCase):
292 295
             [call('Previous node is: ip-192-168-1-2')],
293 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)

Loading…
Cancel
Save