]> 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>
Wed, 16 Jun 2021 02:12:33 +0000 (10:12 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 3908c1f4cd0ebbfdcaae2d9e6de5c1609523cc55)

qa/tasks/ceph_manager.py

index 3e1a2ec51eab982fe0e5b2c02084a79f11361917..b212278ff849911d297df1a32231c845d3724476 100644 (file)
@@ -2560,13 +2560,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):