Skip to content

Commit

Permalink
qa/tasks/ceph: update_archive_setting() only if ctx.archive is valid
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Nov 14, 2020
1 parent a0e1a8f commit de71f6b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions qa/tasks/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit de71f6b

Please sign in to comment.