From da76f4646157d518a325d5534c30f59aba8fc0e6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 30 Jul 2020 23:20:35 +0800 Subject: [PATCH] qa/tasks/ceph: redirect stderr to log file crimson write log to stderr, let's redirect it to log file for a more peaceful teuthology.log. Signed-off-by: Kefu Chai --- qa/tasks/ceph.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index 71fc2eafae19a..e41e73d854c12 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -538,6 +538,16 @@ def create_simple_monmap(ctx, remote, conf, mons, monmap_output, re.MULTILINE).group(1) return fsid + +def maybe_redirect_stderr(args, config, cluster, type_, id_): + if type_ == 'osd' and \ + config.get('flavor', 'default') != 'crimson': + log_path = f'/var/log/ceph/{cluster}-{type_}.{id_}.log' + return args + [run.Raw('2>>'), log_path] + else: + return args + + @contextlib.contextmanager def cluster(ctx, config): """ @@ -902,23 +912,20 @@ def cluster(ctx, config): for role in teuthology.cluster_roles_of_type(roles_for_host, 'osd', cluster_name): _, _, id_ = teuthology.split_role(role) try: - remote.run( - args=[ - 'sudo', + args = ['sudo', 'MALLOC_CHECK_=3', 'adjust-ulimits', - 'ceph-coverage', - coverage_dir, + 'ceph-coverage', coverage_dir, 'ceph-osd', '--no-mon-config', - '--cluster', - cluster_name, + '--cluster', cluster_name, '--mkfs', '--mkkey', '-i', id_, - '--monmap', monmap_path, - ], - ) + '--monmap', monmap_path] + remote.run( + args=maybe_redirect_stderr(args, config, + cluster_name, 'osd', id_)) except run.CommandFailedError: # try without --no-mon-config.. this may be an upgrade test remote.run( @@ -1367,6 +1374,9 @@ def run_daemon(ctx, config, type_): valgrind_args) run_cmd.extend(run_cmd_tail) + run_cmd = maybe_redirect_stderr(run_cmd, + config, + cluster_name, type_, id_) # always register mgr; don't necessarily start ctx.daemons.register_daemon( -- 2.47.3