From cedce1ff81e5476a3ad57fcbcb5f82d000918131 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Mon, 4 Jun 2018 16:36:28 -0400 Subject: [PATCH] Bug 1466660 - Remove use-artifact directory from run-task workers after task has finished r=jmaher Right now artifacts from previous tasks are left lying around. We should clean these up in case a task accidentally uses an artifact from the wrong dependency. Ideally we'd cache these properly based on the taskId they came from, but that can be follow-up fodder. MozReview-Commit-ID: HUgvNlqyFav --HG-- extra : rebase_source : fb9c6723598223619993c2695fb588ead3325edb --- taskcluster/ci/source-test/jsshell.yml | 4 ++-- taskcluster/scripts/run-task | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/taskcluster/ci/source-test/jsshell.yml b/taskcluster/ci/source-test/jsshell.yml index b4c2f9961ef9..99edc0a2b33e 100644 --- a/taskcluster/ci/source-test/jsshell.yml +++ b/taskcluster/ci/source-test/jsshell.yml @@ -28,7 +28,7 @@ bench-ares6: run: command: > cd $USE_ARTIFACT_PATH/build && - unzip -q -d jsshell target.jsshell.zip && + unzip -qo -d jsshell target.jsshell.zip && export JSSHELL=$USE_ARTIFACT_PATH/build/jsshell/js && cd $GECKO_PATH && ./mach jsshell-bench --binary $JSSHELL --perfherder ares6 @@ -40,7 +40,7 @@ bench-sixspeed: run: command: > cd $USE_ARTIFACT_PATH/build && - unzip -q -d jsshell target.jsshell.zip && + unzip -qo -d jsshell target.jsshell.zip && export JSSHELL=$USE_ARTIFACT_PATH/build/jsshell/js && cd $GECKO_PATH && ./mach jsshell-bench --binary $JSSHELL --perfherder six-speed diff --git a/taskcluster/scripts/run-task b/taskcluster/scripts/run-task index c643de22877f..451703c31469 100755 --- a/taskcluster/scripts/run-task +++ b/taskcluster/scripts/run-task @@ -28,6 +28,7 @@ import io import json import os import re +import shutil import socket import stat import subprocess @@ -707,9 +708,10 @@ def main(args): print('task should be defined in terms of non-symbolic revision') return 1 + use_artifact_path = os.environ.get('USE_ARTIFACT_PATH') + def prepare_use_artifact(key, url): print_line(b'setup', b'fetching artifact from %s\n' % url.encode('utf-8')) - use_artifact_path = os.environ['USE_ARTIFACT_PATH'] path = os.path.join(use_artifact_path, key) if not os.path.isdir(path): os.makedirs(path) @@ -727,7 +729,11 @@ def main(args): for url in urls: prepare_use_artifact(key, url) - return run_and_prefix_output(b'task', task_args) + try: + return run_and_prefix_output(b'task', task_args) + finally: + if use_artifact_path and os.path.isdir(use_artifact_path): + shutil.rmtree(use_artifact_path) if __name__ == '__main__':