Bug 1385094 - Allow support for taskgraph taks to refer to indexed docker images, in addition to in-tree and docker-hub images. draft
authorTom Prince <mozilla@hocat.ca>
Thu, 27 Jul 2017 14:39:51 -0600
changeset 617060 24354c2b003cb243c9a3f137354c7e7b00c1379e
parent 615176 32d9d1e81cc607320a36391845917f645f7a7f72
child 639685 42ff77a6086ec8167ba7ae871e219d3c037863a7
child 647687 c37d19aba341617034d00ffd69ba9dcf72816e79
push id70910
push userbmo:mozilla@hocat.ca
push dateThu, 27 Jul 2017 20:40:28 +0000
bugs1385094
milestone56.0a1
Bug 1385094 - Allow support for taskgraph taks to refer to indexed docker images, in addition to in-tree and docker-hub images. MozReview-Commit-ID: HFmsBswwsA1
taskcluster/taskgraph/transforms/task.py
taskcluster/taskgraph/transforms/tests.py
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -160,17 +160,19 @@ task_description_schema = Schema({
         # For tasks that will run in docker-worker or docker-engine, this is the
         # name of the docker image or in-tree docker image to run the task in.  If
         # in-tree, then a dependency will be created automatically.  This is
         # generally `desktop-test`, or an image that acts an awful lot like it.
         Required('docker-image'): Any(
             # a raw Docker image path (repo/image:tag)
             basestring,
             # an in-tree generated docker image (from `taskcluster/docker/<name>`)
-            {'in-tree': basestring}
+            {'in-tree': basestring},
+            # an indexed docker image
+            {'indexed': basestring},
         ),
 
         # worker features that should be enabled
         Required('relengapi-proxy', default=False): bool,
         Required('chain-of-trust', default=False): bool,
         Required('taskcluster-proxy', default=False): bool,
         Required('allow-ptrace', default=False): bool,
         Required('loopback-video', default=False): bool,
@@ -563,23 +565,33 @@ def index_builder(name):
 
 
 @payload_builder('docker-worker')
 def build_docker_worker_payload(config, task, task_def):
     worker = task['worker']
 
     image = worker['docker-image']
     if isinstance(image, dict):
-        docker_image_task = 'build-docker-image-' + image['in-tree']
-        task.setdefault('dependencies', {})['docker-image'] = docker_image_task
-        image = {
-            "path": "public/image.tar.zst",
-            "taskId": {"task-reference": "<docker-image>"},
-            "type": "task-image",
-        }
+        if 'in-tree' in image:
+            docker_image_task = 'build-docker-image-' + image['in-tree']
+            task.setdefault('dependencies', {})['docker-image'] = docker_image_task
+
+            image = {
+                "path": "public/image.tar.zst",
+                "taskId": {"task-reference": "<docker-image>"},
+                "type": "task-image",
+            }
+        elif 'indexed' in image:
+            image = {
+                "path": "public/image.tar.zst",
+                "namespace": image['indexed'],
+                "type": "indexed-image",
+            }
+        else:
+            raise Exception("unknown docker image type")
 
     features = {}
 
     if worker.get('relengapi-proxy'):
         features['relengAPIProxy'] = True
 
     if worker.get('taskcluster-proxy'):
         features['taskclusterProxy'] = True
--- a/taskcluster/taskgraph/transforms/tests.py
+++ b/taskcluster/taskgraph/transforms/tests.py
@@ -211,17 +211,19 @@ test_description_schema = Schema({
     # in-tree, then a dependency will be created automatically.  This is
     # generally `desktop-test`, or an image that acts an awful lot like it.
     Required('docker-image', default={'in-tree': 'desktop-test'}): optionally_keyed_by(
         'test-platform',
         Any(
             # a raw Docker image path (repo/image:tag)
             basestring,
             # an in-tree generated docker image (from `taskcluster/docker/<name>`)
-            {'in-tree': basestring}
+            {'in-tree': basestring},
+            # an indexed docker image
+            {'indexed': basestring},
         )
     ),
 
     # seconds of runtime after which the task will be killed.  Like 'chunks',
     # this can be keyed by test pltaform.
     Required('max-run-time', default=3600): optionally_keyed_by(
         'test-platform',
         int),