Bug 1397503 - Perform cache sanitization for image_builder tasks; r?dustin
The image_builder Docker image doesn't set a "command" in its task
definition. The image instead relies on a RUN in its Dockerfile to
control the started command. This command is a shell script which
eventually runs run-task.
This all means that image_builder tasks are executing run-task but
the cache sanitization implemented in
bug 1391476 isn't getting
applied to those tasks. This means run-task could barf due to
constraint violations due to improperly configured caches.
The fix for this is to teach the generic task transform that
image_builder tasks use run-task. The effect of this is that
some environment variables get set and the cache name changes
depending on the contents of run-task.
MozReview-Commit-ID: IFqsDxD0eDh
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -695,17 +695,27 @@ def build_docker_worker_payload(config,
for artifact in worker['artifacts']:
artifacts[artifact['name']] = {
'path': artifact['path'],
'type': artifact['type'],
'expires': task_def['expires'], # always expire with the task
}
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']
+ else:
+ out_of_tree_image = None
+
+ run_task = any([
+ payload.get('command', [''])[0].endswith('run-task'),
+ # image_builder is special and doesn't get detected like other tasks.
+ # It uses run-task so it needs our cache manipulations.
+ (out_of_tree_image or '').startswith('taskcluster/image_builder'),
+ ])
if 'caches' in worker:
caches = {}
# run-task knows how to validate caches.
#
# To help ensure new run-task features and bug fixes don't interfere
# with existing caches, we seed the hash of run-task into cache names.