]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephadm.py: add ceph logs directory in job's info.yaml
authorShraddha Agrawal <shraddha.agrawal000@gmail.com>
Wed, 19 Aug 2020 10:54:18 +0000 (16:24 +0530)
committerSebastian Wagner <sebastian.wagner@suse.com>
Mon, 7 Sep 2020 09:01:03 +0000 (11:01 +0200)
This commit adds the file path of ceph log directories to the job's
info.yaml log file. The motivation behind this is, in case of job
timeout, the logs would still be tranferred to teuthology host
before nuking test machines using these ceph log directory paths in
job's info.yaml log file.

Signed-off-by: Shraddha Agrawal <shraddha.agrawal000@gmail.com>
(cherry picked from commit d2ff5c5eb609eba02e6c966015bb7e1d9b349be4)

Conflicts:
qa/tasks/cephadm.py

qa/tasks/cephadm.py

index 42b6f3e9834e6804d78ada42db1c7fabc0669583..05408b2f0547fa7e0e713f87e6e9f392b3056ccf 100644 (file)
@@ -10,6 +10,7 @@ import os
 import json
 import re
 import uuid
+import yaml
 
 import six
 import toml
@@ -160,6 +161,16 @@ def ceph_log(ctx, config):
     cluster_name = config['cluster']
     fsid = ctx.ceph[cluster_name].fsid
 
+    # Add logs directory to job's info log file
+    with open(os.path.join(ctx.archive, 'info.yaml'), 'r+') as info_file:
+        info_yaml = yaml.safe_load(info_file)
+        info_file.seek(0)
+        if 'archive' not in info_yaml:
+            info_yaml['archive'] = {'log': '/var/log/ceph'}
+        else:
+            info_yaml['archive']['log'] = '/var/log/ceph'
+        yaml.safe_dump(info_yaml, info_file, default_flow_style=False)
+
     try:
         yield
 
@@ -267,6 +278,16 @@ def ceph_crash(ctx, config):
     cluster_name = config['cluster']
     fsid = ctx.ceph[cluster_name].fsid
 
+    # Add logs directory to job's info log file
+    with open(os.path.join(ctx.archive, 'info.yaml'), 'r+') as info_file:
+        info_yaml = yaml.safe_load(info_file)
+        info_file.seek(0)
+        if 'archive' not in info_yaml:
+            info_yaml['archive'] = {'crash': '/var/lib/ceph/%s/crash' % fsid}
+        else:
+            info_yaml['archive']['crash'] = '/var/lib/ceph/%s/crash' % fsid
+        yaml.safe_dump(info_yaml, info_file, default_flow_style=False)
+
     try:
         yield
 
@@ -309,7 +330,7 @@ def ceph_bootstrap(ctx, config, registry):
     first_mon = ctx.ceph[cluster_name].first_mon
     first_mon_role = ctx.ceph[cluster_name].first_mon_role
     mons = ctx.ceph[cluster_name].mons
-    
+
     ctx.cluster.run(args=[
         'sudo', 'mkdir', '-p', '/etc/ceph',
         ]);
@@ -471,7 +492,7 @@ def ceph_bootstrap(ctx, config, registry):
                 ctx.daemons.get_daemon(type_, id_, cluster).stop()
             except Exception:
                 log.exception('Failed to stop "{role}"'.format(role=role))
-                raise 
+                raise
 
         # clean up /etc/ceph
         ctx.cluster.run(args=[
@@ -1135,7 +1156,7 @@ def task(ctx, config):
     if cluster_name not in ctx.ceph:
         ctx.ceph[cluster_name] = argparse.Namespace()
         ctx.ceph[cluster_name].bootstrapped = False
+
     # image
     teuth_defaults = teuth_config.get('defaults', {})
     cephadm_defaults = teuth_defaults.get('cephadm', {})
@@ -1255,9 +1276,9 @@ def registries_add_mirror_to_docker_io(conf, mirror):
 
 def add_mirror_to_cluster(ctx, mirror):
     log.info('Adding local image mirror %s' % mirror)
-    
+
     registries_conf = '/etc/containers/registries.conf'
-    
+
     for remote in ctx.cluster.remotes.keys():
         try:
             config = teuthology.get_file(