Merge pull request #6301 from gamuniz/catch_analytics_failure

rework the gather() to always delete the leftover directories

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-03-16 20:45:36 +00:00
committed by GitHub

View File

@@ -134,13 +134,17 @@ def gather(dest=None, module=None, collection_type='scheduled'):
settings.SYSTEM_UUID, settings.SYSTEM_UUID,
run_now.strftime('%Y-%m-%d-%H%M%S%z') run_now.strftime('%Y-%m-%d-%H%M%S%z')
]) ])
tgz = shutil.make_archive( try:
os.path.join(os.path.dirname(dest), tarname), tgz = shutil.make_archive(
'gztar', os.path.join(os.path.dirname(dest), tarname),
dest 'gztar',
) dest
shutil.rmtree(dest) )
return tgz return tgz
except Exception:
logger.exception("Failed to write analytics archive file")
finally:
shutil.rmtree(dest)
def ship(path): def ship(path):