Bug 1334401 - Prefer docker images from higher levels. r?jonasfj draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 27 Jan 2017 16:18:02 +0900
changeset 467565 79706b7a184d8a38df6eaff61832a29b776efc4f
parent 467180 bdaabccd427cfc8e98cda64e7e01d9865d230c9b
child 543729 68e289c57b968ca51378db944c77205f703a8ab1
push id43224
push userbmo:mh+mozilla@glandium.org
push dateSat, 28 Jan 2017 04:34:34 +0000
reviewersjonasfj
bugs1334401
milestone54.0a1
Bug 1334401 - Prefer docker images from higher levels. r?jonasfj Considering docker images contents depend very much on the moment they were built, it is possible that two images with the same hash in the taskcluster index (at different levels) have different contents. When this happens, the build or test results could be significantly different between e.g. try and mozilla-central, possibly leading to misleading results at landing time. So if for some reason multiple levels have images for the same hash, the one used at the highest level should be prefered, such that try uses the same as mozilla-central once mozilla-central generates the image for that hash, even if there is an image previously generated for try.
taskcluster/taskgraph/task/docker_image.py
taskcluster/taskgraph/test/test_taskgraph.py
--- a/taskcluster/taskgraph/task/docker_image.py
+++ b/taskcluster/taskgraph/task/docker_image.py
@@ -82,17 +82,17 @@ class DockerImageTask(base.Task):
 
             # As an optimization, if the context hash exists for a high level, that image
             # task ID will be used.  The reasoning behind this is that eventually everything ends
             # up on level 3 at some point if most tasks use this as a common image
             # for a given context hash, a worker within Taskcluster does not need to contain
             # the same image per branch.
             index_paths = ['{}.level-{}.{}.hash.{}'.format(
                                 INDEX_PREFIX, level, image_name, context_hash)
-                           for level in range(int(params['level']), 4)]
+                           for level in reversed(range(int(params['level']), 4))]
 
             tasks.append(cls(kind, 'build-docker-image-' + image_name,
                              task=image_task['task'], attributes=attributes,
                              index_paths=index_paths))
 
         return tasks
 
     def get_dependencies(self, taskgraph):
@@ -123,15 +123,15 @@ class DockerImageTask(base.Task):
     @classmethod
     def from_json(cls, task_dict):
         # Generating index_paths for optimization
         imgMeta = task_dict['task']['extra']['imageMeta']
         image_name = imgMeta['imageName']
         context_hash = imgMeta['contextHash']
         index_paths = ['{}.level-{}.{}.hash.{}'.format(
                             INDEX_PREFIX, level, image_name, context_hash)
-                       for level in range(int(imgMeta['level']), 4)]
+                       for level in reversed(range(int(imgMeta['level']), 4))]
         docker_image_task = cls(kind='docker-image',
                                 label=task_dict['label'],
                                 attributes=task_dict['attributes'],
                                 task=task_dict['task'],
                                 index_paths=index_paths)
         return docker_image_task
--- a/taskcluster/taskgraph/test/test_taskgraph.py
+++ b/taskcluster/taskgraph/test/test_taskgraph.py
@@ -23,17 +23,17 @@ class TestTargetTasks(unittest.TestCase)
                 "imageMeta": {
                     "contextHash": "<hash>",
                     "imageName": "<image>",
                     "level": "1"
                 }
             }
         }
         index_paths = ["{}.level-{}.<image>.hash.<hash>".format(INDEX_PREFIX, level)
-                       for level in range(1, 4)]
+                       for level in reversed(range(1, 4))]
         graph = TaskGraph(tasks={
             'a': TransformTask(
                 kind='fancy',
                 task={
                     'label': 'a',
                     'attributes': {},
                     'dependencies': {},
                     'when': {},