Bug 1397503 - Perform cache sanitization for image_builder tasks; r?dustin draft
authorGregory Szorc <gps@mozilla.com>
Wed, 06 Sep 2017 15:35:13 -0700
changeset 660427 5393c21a4ca0ad487d494c74bc9e251c9b248a53
parent 659873 c959327c6b75cd4930a6ea087583c38b805e7524
child 660428 20fb5b0b3c9eb48c3e0eed76c2be90893d0179e2
child 661123 9703b2c00c55cdc115adc2836db6578855c36705
push id78400
push usergszorc@mozilla.com
push dateWed, 06 Sep 2017 23:39:19 +0000
reviewersdustin
bugs1397503, 1391476
milestone57.0a1
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
taskcluster/taskgraph/transforms/task.py
--- 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.