]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/ceph: add mon-health-to-clog option to "restart"
authorKefu Chai <kchai@redhat.com>
Wed, 29 Nov 2017 04:19:35 +0000 (12:19 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Nov 2017 12:04:44 +0000 (20:04 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph.py

index 75b3b502df4ee1ca9aa9d2be5eb0aa16002787ed..177fb0d2db2d04dad6d5ca2239d32135751d6552 100644 (file)
@@ -1344,6 +1344,39 @@ def created_pool(ctx, config):
                 new_pool, 'pg_num')
 
 
+@contextlib.contextmanager
+def tweaked_option(ctx, config):
+    """
+    set an option, and then restore it with its original value
+
+    Note, due to the way how tasks are executed/nested, it's not suggested to
+    use this method as a standalone task. otherwise, it's likely that it will
+    restore the tweaked option at the /end/ of 'tasks' block.
+    """
+    saved_options = {}
+    # we can complicate this when necessary
+    options = ['mon-health-to-clog']
+    type_, id_ = 'mon', '*'
+    cluster = config.get('cluster', 'ceph')
+    manager = ctx.managers[cluster]
+    if id_ == '*':
+        get_from = next(teuthology.all_roles_of_type(ctx.cluster, type_))
+    else:
+        get_from = id_
+    for option in options:
+        if option not in config:
+            continue
+        value = 'true' if config[option] else 'false'
+        option = option.replace('-', '_')
+        old_value = manager.get_config(type_, get_from, option)
+        if value != old_value:
+            saved_options[option] = old_value
+            manager.inject_args(type_, id_, option, value)
+    yield
+    for option, value in saved_options.items():
+        manager.inject_args(type_, id_, option, value)
+
+
 @contextlib.contextmanager
 def restart(ctx, config):
     """
@@ -1375,12 +1408,14 @@ def restart(ctx, config):
 
     daemons = ctx.daemons.resolve_role_list(config.get('daemons', None), CEPH_ROLE_TYPES, True)
     clusters = set()
-    for role in daemons:
-        cluster, type_, id_ = teuthology.split_role(role)
-        ctx.daemons.get_daemon(type_, id_, cluster).restart()
-        clusters.add(cluster)
-
     manager = ctx.managers['ceph']
+
+    with tweaked_option(ctx, config):
+        for role in daemons:
+            cluster, type_, id_ = teuthology.split_role(role)
+            ctx.daemons.get_daemon(type_, id_, cluster).restart()
+            clusters.add(cluster)
+
     for dmon in daemons:
         if '.' in dmon:
             dm_parts = dmon.split('.')