]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/ceph2: use safe_while
authorSage Weil <sage@redhat.com>
Thu, 21 Nov 2019 16:48:27 +0000 (10:48 -0600)
committerSage Weil <sage@redhat.com>
Thu, 21 Nov 2019 21:35:36 +0000 (15:35 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
qa/tasks/ceph2.py

index 20c949ac1b3a1586b729d85603bf9f4f992bbed7..3290d90e0484878460f0fcd0add8d5182e0678e9 100644 (file)
@@ -405,21 +405,21 @@ def ceph_mons(ctx, config):
                     started=True,
                 )
 
-                while True:
-                    log.info('Waiting for %d mons in monmap...' % (num_mons))
-                    r = shell(
-                        ctx=ctx,
-                        cluster_name=cluster_name,
-                        remote=remote,
-                        args=[
-                            'ceph', 'mon', 'dump', '-f', 'json',
-                        ],
-                        stdout=StringIO(),
-                    )
-                    j = json.loads(r.stdout.getvalue())
-                    if len(j['mons']) == num_mons:
-                        break
-                    time.sleep(1)
+                with contextutil.safe_while(sleep=1, tries=180) as proceed:
+                    while proceed():
+                        log.info('Waiting for %d mons in monmap...' % (num_mons))
+                        r = shell(
+                            ctx=ctx,
+                            cluster_name=cluster_name,
+                            remote=remote,
+                            args=[
+                                'ceph', 'mon', 'dump', '-f', 'json',
+                            ],
+                            stdout=StringIO(),
+                        )
+                        j = json.loads(r.stdout.getvalue())
+                        if len(j['mons']) == num_mons:
+                            break
 
         # refresh ceph.conf files for all mons + first mgr
         """