]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/ceph.py: add ceph logs directory in job's info.yaml
authorShraddha Agrawal <shraddha.agrawal000@gmail.com>
Mon, 20 Jul 2020 21:03:12 +0000 (02:33 +0530)
committerLaura Flores <lflores@redhat.com>
Wed, 4 May 2022 15:34:41 +0000 (10:34 -0500)
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 e991f04b59b96271042f749ab1b7b9c56701c4f9)

qa/tasks/ceph.py

index 848cdae3eb8ec67c6573f7f2983d110c6091a274..2f98dbd39371fb857bfcaf3d65f12f069754963e 100644 (file)
@@ -17,6 +17,7 @@ import time
 import gevent
 import re
 import socket
+import yaml
 
 from paramiko import SSHException
 from tasks.ceph_manager import CephManager, write_conf
@@ -75,8 +76,19 @@ def generate_caps(type_):
 @contextlib.contextmanager
 def ceph_crash(ctx, config):
     """
-    Gather crash dumps from /var/lib/crash
+    Gather crash dumps from /var/lib/ceph/crash
     """
+
+    # 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/crash'}
+        else:
+            info_yaml['archive']['crash'] = '/var/lib/ceph/crash'
+        yaml.safe_dump(info_yaml, info_file, default_flow_style=False)
+
     try:
         yield
 
@@ -146,6 +158,16 @@ def ceph_log(ctx, config):
         )
     )
 
+    # 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)
+
     class Rotater(object):
         stop_event = gevent.event.Event()
 
@@ -1523,7 +1545,7 @@ def restart(ctx, config):
                 ctx.managers[cluster].mark_down_osd(id_)
             ctx.daemons.get_daemon(type_, id_, cluster).restart()
             clusters.add(cluster)
-    
+
     if config.get('wait-for-healthy', True):
         for cluster in clusters:
             healthy(ctx=ctx, config=dict(cluster=cluster))