From 96e9b8bc29ffab0b99b1b103bd78acf9ae555db5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 21 Nov 2019 10:48:27 -0600 Subject: [PATCH] qa/tasks/ceph2: use safe_while Signed-off-by: Sage Weil --- qa/tasks/ceph2.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/qa/tasks/ceph2.py b/qa/tasks/ceph2.py index 20c949ac1b3..3290d90e048 100644 --- a/qa/tasks/ceph2.py +++ b/qa/tasks/ceph2.py @@ -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 """ -- 2.39.5