]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
ceph: add wait_for_mon_quorum command
authorSage Weil <sage@inktank.com>
Tue, 23 Jul 2013 21:43:56 +0000 (14:43 -0700)
committerSage Weil <sage@inktank.com>
Tue, 23 Jul 2013 22:38:29 +0000 (15:38 -0700)
tasks:
...
- ceph.wait_for_mon_quorum: [a, b]
...

will block until the mon quorum consists of exactly [a, b].  This is
compared directly to the relevant field from 'ceph quorum_status'
which has the alphanumeric names only.

Signed-off-by: Sage Weil <sage@inktank.com>
teuthology/task/ceph.py

index 4b2cca629ce6dd88bc57e6c4185fefd35c394f98..fd1c780c7a5f3e8b4c1bf58752023ec5751eb814 100644 (file)
@@ -936,6 +936,29 @@ def healthy(ctx, config):
         remote=mon0_remote,
         )
 
+def wait_for_mon_quorum(ctx, config):
+    import json
+    import time
+
+    assert isinstance(config, list)
+    firstmon = teuthology.get_first_mon(ctx, config)
+    (remote,) = ctx.cluster.only(firstmon).remotes.keys()
+    while True:
+        r = remote.run(
+            args=[
+                'ceph',
+                'quorum_status',
+                ],
+            stdout=StringIO(),
+            logger=log.getChild('quorum_status'),
+            )
+        j = json.loads(r.stdout.getvalue())
+        q = j.get('quorum_names', [])
+        log.debug('Quorum: %s', q)
+        if sorted(q) == sorted(config):
+            break
+        time.sleep(1)
+
 
 @contextlib.contextmanager
 def restart(ctx, config):