]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/ceph_manager: use safe_while() to refactor the wait for quorum
authorKefu Chai <kchai@redhat.com>
Thu, 10 Jun 2021 12:10:06 +0000 (20:10 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 10 Jun 2021 12:29:50 +0000 (20:29 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph_manager.py

index 8a2a6e52ee09b5af174191c6392c37eb60683e3f..611c4ba6f928120c6345ffc3f4be78782477475d 100644 (file)
@@ -3091,13 +3091,13 @@ class CephManager:
         Loop until quorum size is reached.
         """
         self.log('waiting for quorum size %d' % size)
-        start = time.time()
-        while not len(self.get_mon_quorum()) == size:
-            if timeout is not None:
-                assert time.time() - start < timeout, \
-                    ('failed to reach quorum size %d '
-                     'before timeout expired' % size)
-            time.sleep(3)
+        sleep = 3
+        with safe_while(sleep=sleep,
+                        tries=timeout // sleep,
+                        action=f'wait for quorum size {size}') as proceed:
+            while proceed():
+                if len(self.get_mon_quorum()) == size:
+                    break
         self.log("quorum is size %d" % size)
 
     def get_mon_health(self, debug=False):