Bug 1274645: generate task labels for docker image builds; r?ahal draft
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 20 May 2016 21:04:49 +0000
changeset 369225 a50322a6ad137d3a1dfc968a019130b92fc2a8fa
parent 369224 c403ac05b8f42e44a5f7a0c98c2bf190b28706b1
child 521514 fba8571c46948a8d2fed1192457406eb61dda852
push id18797
push userdmitchell@mozilla.com
push dateFri, 20 May 2016 21:06:56 +0000
reviewersahal
bugs1274645
milestone49.0a1
Bug 1274645: generate task labels for docker image builds; r?ahal This monkey-patches the old taskcluster_graph code to avoid impacting branches that are still using that support for decision graphs. All of this will go away when docker image builds become their own kind. MozReview-Commit-ID: KukC3qqZDYA
taskcluster/taskgraph/kind/legacy.py
testing/taskcluster/taskcluster_graph/image_builder.py
--- a/taskcluster/taskgraph/kind/legacy.py
+++ b/taskcluster/taskgraph/kind/legacy.py
@@ -54,16 +54,20 @@ DEFAULT_JOB_PATH = os.path.join(
 # time after which a try build's results will expire
 TRY_EXPIRATION = "14 days"
 
 logger = logging.getLogger(__name__)
 
 def mklabel():
     return TASKID_PLACEHOLDER.format(slugid())
 
+# monkey-patch mklabel into image_builder, as well
+from taskcluster_graph import image_builder
+image_builder.mklabel = mklabel
+
 def set_expiration(task, timestamp):
     task_def = task['task']
     task_def['expires'] = timestamp
     if task_def.get('deadline', timestamp) > timestamp:
         task_def['deadline'] = timestamp
 
     try:
         artifacts = task_def['payload']['artifacts']
--- a/testing/taskcluster/taskcluster_graph/image_builder.py
+++ b/testing/taskcluster/taskcluster_graph/image_builder.py
@@ -17,16 +17,22 @@ DOCKER_ROOT = os.path.join(GECKO, 'testi
 REGISTRY = open(os.path.join(DOCKER_ROOT, 'REGISTRY')).read().strip()
 INDEX_URL = 'https://index.taskcluster.net/v1/task/docker.images.v1.{}.{}.hash.{}'
 ARTIFACT_URL = 'https://queue.taskcluster.net/v1/task/{}/artifacts/{}'
 DEFINE_TASK = 'queue:define-task:aws-provisioner-v1/{}'
 
 def is_docker_registry_image(registry_path):
     return os.path.isfile(registry_path)
 
+# make a task label; in old decision tasks, this is a regular slugid, but when called
+# from the taskgraph generator's legacy kind, this is monkey-patched to return a label
+# (`TaskLabel==..`)
+def mklabel():
+    return slugid()
+
 def docker_image(name):
     ''' Determine the docker tag/revision from an in tree docker file '''
     repository_path = os.path.join(DOCKER_ROOT, name, 'REGISTRY')
     repository = REGISTRY
 
     version = open(os.path.join(DOCKER_ROOT, name, 'VERSION')).read().strip()
 
     if os.path.isfile(repository_path):
@@ -44,17 +50,17 @@ def task_id_for_image(seen_images, proje
 
     if task_id:
         seen_images[name] = {'taskId': task_id}
         return task_id
 
     if not create:
         return None
 
-    task_id = slugid()
+    task_id = mklabel()
     seen_images[name] = {
         'taskId': task_id,
         'path': context_path,
         'hash': context_hash
     }
 
     return task_id