From de71f6b0a31ee3629bd60f6714a314caa59ae73f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 10 Nov 2020 14:40:25 +0800 Subject: [PATCH] qa/tasks/ceph: update_archive_setting() only if ctx.archive is valid 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 Signed-off-by: Kefu Chai --- qa/tasks/ceph.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index b088902706c..0f547576f4c 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -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()