]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/ceph: update_archive_setting() only if ctx.archive is valid
authorKefu Chai <kchai@redhat.com>
Tue, 10 Nov 2020 06:40:25 +0000 (14:40 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 14 Nov 2020 07:22:00 +0000 (15:22 +0800)
When running teuthology interactively, ctx.archive might not be set.
If it's not set, there is no point trying to access files there.

Fixes: https://tracker.ceph.com/issues/48058
Signed-off-by: Marcus Watts <mwatts@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph.py

index b088902706cfbf9547b21ae3d8176a93dbe0adc6..0f547576f4c3552fa06b25f1cf070530eaf7dcff 100644 (file)
@@ -73,8 +73,8 @@ def generate_caps(type_):
         yield capability
 
 
-def update_archive_setting(ctx, key, value):
-    with open(os.path.join(ctx.archive, 'info.yaml'), 'r+') as info_file:
+def update_archive_setting(archive_dir, key, value):
+    with open(os.path.join(archive_dir, 'info.yaml'), 'r+') as info_file:
         info_yaml = yaml.safe_load(info_file)
         info_file.seek(0)
         if 'archive' in info_yaml:
@@ -90,8 +90,9 @@ def ceph_crash(ctx, config):
     Gather crash dumps from /var/lib/ceph/crash
     """
 
-    # Add crash directory to job's archive
-    update_archive_setting(ctx, 'crash', '/var/lib/ceph/crash')
+    if ctx.archive is not None:
+        # Add crash directory to job's archive
+        update_archive_setting(ctx.archive, 'crash', '/var/lib/ceph/crash')
 
     try:
         yield
@@ -163,7 +164,8 @@ def ceph_log(ctx, config):
     )
 
     # Add logs directory to job's info log file
-    update_archive_setting(ctx, 'log', '/var/log/ceph')
+    if ctx.archive is not None:
+        update_archive_setting(ctx.archive, 'log', '/var/log/ceph')
 
     class Rotater(object):
         stop_event = gevent.event.Event()