]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: add wait_for_failure command
authorSage Weil <sage@redhat.com>
Fri, 23 Jan 2015 23:20:50 +0000 (15:20 -0800)
committerSage Weil <sage@redhat.com>
Fri, 23 Jan 2015 23:20:50 +0000 (15:20 -0800)
Expect and then ignore a daemon failure.

Signed-off-by: Sage Weil <sage@redhat.com>
tasks/ceph.py

index d8366fa0ba263795351fb3dd463f3361fef442df..36805ca58c0d67c68e243c6e265539a346ef8761 100644 (file)
@@ -1097,6 +1097,42 @@ def stop(ctx, config):
 
     yield
 
+@contextlib.contextmanager
+def wait_for_failure(ctx, config):
+    """
+    Wait for a failure of a ceph daemon
+
+    For example::
+      tasks:
+      - ceph.wait_for_failure: [mds.*]
+
+      tasks:
+      - ceph.wait_for_failure: [osd.0, osd.2]
+
+      tasks:
+      - ceph.wait_for_failure:
+          daemons: [osd.0, osd.2]
+
+    """
+    if config is None:
+        config = {}
+    elif isinstance(config, list):
+        config = {'daemons': config}
+
+    daemons = ctx.daemons.resolve_role_list(config.get('daemons', None), CEPH_ROLE_TYPES)
+    for i in daemons:
+        type_ = i.split('.', 1)[0]
+        id_ = i.split('.', 1)[1]
+        try:
+            ctx.daemons.get_daemon(type_, id_).wait()
+        except:
+            log.info('Saw expected daemon failure.  Continuing.')
+            pass
+        else:
+            raise RuntimeError('daemon %s did not fail' % i)
+
+    yield
+
 
 @contextlib.contextmanager
 def task(ctx, config):