From be05f210e7c71dad767a6e4e46425f6ba15c7cf1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 23 Jan 2020 17:12:21 -0600 Subject: [PATCH] qa/tasks/ceph: simplify mon_health_to_clog suppression during restart This only does one thing--do that. More simply. Signed-off-by: Sage Weil --- qa/tasks/ceph.py | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index fad9d1e4e67..d18366bcff4 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -1532,37 +1532,27 @@ def created_pool(ctx, config): @contextlib.contextmanager -def tweaked_option(ctx, config): +def suppress_mon_health_to_clog(ctx, config): """ - set an option, and then restore it with its original value + set the 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_)) + if config.get('mon-health-to-clog', 'true') == 'false': + saved_options = {} + cluster = config.get('cluster', 'ceph') + manager = ctx.managers[cluster] + manager.raw_cluster_command( + 'config', 'set', 'mon', 'mon_health_to_clog', 'false' + ) + yield + manager.raw_cluster_command( + 'config', 'rm', 'mon', 'mon_health_to_clog' + ) 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) - + yield @contextlib.contextmanager def restart(ctx, config): @@ -1596,7 +1586,7 @@ def restart(ctx, config): daemons = ctx.daemons.resolve_role_list(config.get('daemons', None), CEPH_ROLE_TYPES, True) clusters = set() - with tweaked_option(ctx, config): + with suppress_mon_health_to_clog(ctx, config): for role in daemons: cluster, type_, id_ = teuthology.split_role(role) ctx.daemons.get_daemon(type_, id_, cluster).stop() -- 2.39.5