From: Sage Weil Date: Fri, 23 Jan 2015 23:20:50 +0000 (-0800) Subject: ceph: add wait_for_failure command X-Git-Tag: v0.94.10~27^2^2~188^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=83dd3d58a154e2fa8939cc3041b0cac2f577f4c5;p=ceph.git ceph: add wait_for_failure command Expect and then ignore a daemon failure. Signed-off-by: Sage Weil --- diff --git a/tasks/ceph.py b/tasks/ceph.py index d8366fa0ba26..36805ca58c0d 100644 --- a/tasks/ceph.py +++ b/tasks/ceph.py @@ -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):