]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/ceph: redirect stderr to log file
authorKefu Chai <kchai@redhat.com>
Thu, 30 Jul 2020 15:20:35 +0000 (23:20 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 30 Jul 2020 16:51:30 +0000 (00:51 +0800)
crimson write log to stderr, let's redirect it to log file for a more
peaceful teuthology.log.

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph.py

index 71fc2eafae19ad09017c5aed374f0be24563a454..e41e73d854c120a3ad6b4fb765cd6459c9c347b5 100644 (file)
@@ -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(