mirror of
https://github.com/ceph/ceph
synced 2025-02-22 02:27:29 +00:00
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 <sage@redhat.com>
This commit is contained in:
parent
10ffeef1fb
commit
be05f210e7
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user