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 <mwatts@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2020-11-10 14:40:25 +08:00
parent a0e1a8f173
commit de71f6b0a3

View 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()