Bug 1433975: Error out if a parent docker image isn't present in the configuration; r?dustin draft
authorTom Prince <mozilla@hocat.ca>
Mon, 29 Jan 2018 11:03:06 -0700
changeset 748375 1adcaafb1f3c8692ef372671447325b0ed9bfdcb
parent 748372 c0f08b020685f67a7ea08658731adb410f70b7e6
push id97142
push userbmo:mozilla@hocat.ca
push dateMon, 29 Jan 2018 18:04:45 +0000
reviewersdustin
bugs1433975
milestone60.0a1
Bug 1433975: Error out if a parent docker image isn't present in the configuration; r?dustin MozReview-Commit-ID: ASeCAXLzOEZ
taskcluster/taskgraph/transforms/docker_image.py
--- a/taskcluster/taskgraph/transforms/docker_image.py
+++ b/taskcluster/taskgraph/transforms/docker_image.py
@@ -58,27 +58,31 @@ docker_image_schema = Schema({
 def validate(config, tasks):
     for task in tasks:
         validate_schema(
             docker_image_schema, task,
             "In docker image {!r}:".format(task.get('name', 'unknown')))
         yield task
 
 
-def order_image_tasks(tasks):
+def order_image_tasks(config, tasks):
     """Iterate image tasks in an order where parent images come first."""
     pending = deque(tasks)
+    task_names = {task['name'] for task in pending}
     emitted = set()
     while True:
         try:
             task = pending.popleft()
         except IndexError:
             break
         parent = task.get('parent')
         if parent and parent not in emitted:
+            if parent not in task_names:
+                raise Exception('Missing parant image for {}-{}: {}'.format(
+                    config.kind, task['name'], parent))
             pending.append(task)
             continue
         emitted.add(task['name'])
         yield task
 
 
 @transforms.add
 def fill_template(config, tasks):
@@ -92,17 +96,17 @@ def fill_template(config, tasks):
                 # Only keep the hash part of the route.
                 h = route.rsplit('.', 1)[1]
                 assert DIGEST_RE.match(h)
                 available_packages[name] = h
                 break
 
     context_hashes = {}
 
-    for task in order_image_tasks(tasks):
+    for task in order_image_tasks(config, tasks):
         image_name = task.pop('name')
         job_symbol = task.pop('symbol')
         args = task.pop('args', {})
         definition = task.pop('definition', image_name)
         packages = task.pop('packages', [])
         parent = task.pop('parent', None)
 
         for p in packages: