Bug 1364266 - Specify task priority within task definition r?dustin draft
authorGregory Arndt <garndt@mozilla.com>
Fri, 05 May 2017 15:22:03 -0500
changeset 579884 4a13fae1da5ec7d29f0e379069e6b13be2d4ae61
parent 577084 96b36c5f527dd42e680a230839519eee1fc2c9f3
child 629143 cd50e2eadccaeadb61f9fbafd7d0fbcc11af4fa8
push id59397
push usergarndt@mozilla.com
push dateWed, 17 May 2017 23:44:27 +0000
reviewersdustin
bugs1364266
milestone55.0a1
Bug 1364266 - Specify task priority within task definition r?dustin Tasks should be assigned a priority based on the branch they originated from. It is important that certain branches receive preferential treatment, such as a release branch task being executed before a task from Try. Branch priority mirrors the priorities defined within buildbot. MozReview-Commit-ID: 8qR9F34lzzc
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -478,16 +478,52 @@ V2_L10N_TEMPLATES = [
 # the roots of the treeherder routes, keyed by treeherder environment
 TREEHERDER_ROUTE_ROOTS = {
     'production': 'tc-treeherder',
     'staging': 'tc-treeherder-stage',
 }
 
 COALESCE_KEY = 'builds.{project}.{name}'
 
+DEFAULT_BRANCH_PRIORITY = 'low'
+BRANCH_PRIORITIES = {
+    'mozilla-release': 'highest',
+    'comm-esr45': 'highest',
+    'comm-esr52': 'highest',
+    'mozilla-esr45': 'very-high',
+    'mozilla-esr52': 'very-high',
+    'mozilla-beta': 'high',
+    'comm-beta': 'high',
+    'mozilla-central': 'medium',
+    'comm-central': 'medium',
+    'mozilla-aurora': 'medium',
+    'comm-aurora': 'medium',
+    'autoland': 'low',
+    'mozilla-inbound': 'low',
+    'try': 'very-low',
+    'try-comm-central': 'very-low',
+    'alder': 'very-low',
+    'ash': 'very-low',
+    'birch': 'very-low',
+    'cedar': 'very-low',
+    'cypress': 'very-low',
+    'date': 'very-low',
+    'elm': 'very-low',
+    'fig': 'very-low',
+    'gum': 'very-low',
+    'holly': 'very-low',
+    'jamun': 'very-low',
+    'larch': 'very-low',
+    'maple': 'very-low',
+    'oak': 'very-low',
+    'pine': 'very-low',
+    'graphics': 'very-low',
+    'ux': 'very-low',
+}
+
 # define a collection of payload builders, depending on the worker implementation
 payload_builders = {}
 
 
 def payload_builder(name):
     def wrap(func):
         payload_builders[name] = func
         return func
@@ -916,16 +952,21 @@ def build_task(config, tasks):
             task['deadline-after'] = '1 day'
 
         if 'coalesce-name' in task and int(config.params['level']) > 1:
             key = COALESCE_KEY.format(
                 project=config.params['project'],
                 name=task['coalesce-name'])
             routes.append('coalesce.v1.' + key)
 
+        if 'priority' not in task:
+            task['priority'] = BRANCH_PRIORITIES.get(
+                config.params['project'],
+                DEFAULT_BRANCH_PRIORITY)
+
         tags = task.get('tags', {})
         tags.update({'createdForUser': config.params['owner']})
 
         task_def = {
             'provisionerId': provisioner_id,
             'workerType': worker_type,
             'routes': routes,
             'created': {'relative-datestamp': '0 seconds'},
@@ -938,16 +979,17 @@ def build_task(config, tasks):
                 'owner': config.params['owner'],
                 'source': '{}/file/{}/{}'.format(
                     config.params['head_repository'],
                     config.params['head_rev'],
                     config.path),
             },
             'extra': extra,
             'tags': tags,
+            'priority': task['priority'],
         }
 
         if task_th:
             # link back to treeherder in description
             th_push_link = 'https://treeherder.mozilla.org/#/jobs?repo={}&revision={}'.format(
                 config.params['project'], config.params['head_rev'])
             task_def['metadata']['description'] += ' ([Treeherder push]({}))'.format(
                 th_push_link)