Bug 1469687 - Handle EXIT_PURGE_CACHES in all run-task tasks; r=tomprince

Any run-task task could exit with EXIT_PURGE_CACHES and expect the
task to be retried. Before this commit, we only registered this exit
code for tasks "using: run-task." That excluded mozharness and
a handful of other "using" flavors.

With this commit, we register the exit codes for all run-task tasks
by sniffing for the presence of run-task in the low-level code that
emits the task definition. This should prevent run-tasks tasks
from falling through the cracks and not having their exit codes
result in meaningful behavior.

Differential Revision: https://phabricator.services.mozilla.com/D1715
This commit is contained in:
Gregory Szorc
2018-06-19 20:58:29 +00:00
parent 85894b64e1
commit d75ec67c83
2 changed files with 11 additions and 6 deletions

View File

@@ -786,6 +786,17 @@ def build_docker_worker_payload(config, task, task_def):
if 'max-run-time' in worker:
payload['maxRunTime'] = worker['max-run-time']
run_task = payload.get('command', [''])[0].endswith('run-task')
# run-task exits EXIT_PURGE_CACHES if there is a problem with caches.
# Automatically retry the tasks and purge caches if we see this exit
# code.
# TODO move this closer to code adding run-task once bug 1469697 is
# addressed.
if run_task:
worker.setdefault('retry-exit-status', []).append(72)
worker.setdefault('purge-caches-exit-status', []).append(72)
payload['onExitStatus'] = {}
if 'retry-exit-status' in worker:
payload['onExitStatus']['retry'] = worker['retry-exit-status']
@@ -802,8 +813,6 @@ def build_docker_worker_payload(config, task, task_def):
}
payload['artifacts'] = artifacts
run_task = payload.get('command', [''])[0].endswith('run-task')
if isinstance(worker.get('docker-image'), basestring):
out_of_tree_image = worker['docker-image']
run_task = run_task or out_of_tree_image.startswith(