Bug 1391323 - Make action tasks have task group and scheduler set by default draft
authorBrian Stack <bstack@mozilla.com>
Thu, 17 Aug 2017 11:53:55 -0700
changeset 648416 80b3ada4b2c3264cac4d164cc129ce2d8eea63ac
parent 648384 e365137fa61bfd729617ba1ebf9f1ed79facd1f2
child 726822 6ab58013bcfc88b2640306f134e4e137ede8cc64
push id74754
push userbstack@mozilla.com
push dateThu, 17 Aug 2017 18:54:19 +0000
bugs1391323
milestone57.0a1
Bug 1391323 - Make action tasks have task group and scheduler set by default MozReview-Commit-ID: G7oPskaFBVO
taskcluster/taskgraph/actions/registry.py
--- a/taskcluster/taskgraph/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -5,16 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import json
 import os
 import inspect
 import re
+from slugid import nice as slugid
 from mozbuild.util import memoize
 from types import FunctionType
 from collections import namedtuple
 from taskgraph import create
 from taskgraph.util.docker import docker_image
 from taskgraph.parameters import Parameters
 
 
@@ -178,30 +179,34 @@ def register_callback_action(name, title
                 return None
 
             match = re.match(r'https://(hg.mozilla.org)/(.*?)/?$', parameters['head_repository'])
             if not match:
                 raise Exception('Unrecognized head_repository')
             repo_scope = 'assume:repo:{}/{}:*'.format(
                 match.group(1), match.group(2))
 
+            task_group_id = os.environ.get('TASK_ID', slugid())
+
             return {
                 'created': {'$fromNow': ''},
                 'deadline': {'$fromNow': '12 hours'},
                 'expires': {'$fromNow': '14 days'},
                 'metadata': {
                     'owner': 'mozilla-taskcluster-maintenance@mozilla.com',
                     'source': '{}raw-file/{}/{}'.format(
                         parameters['head_repository'], parameters['head_rev'], source_path,
                     ),
                     'name': 'Action: {}'.format(title),
                     'description': 'Task executing callback for action.\n\n---\n' + description,
                 },
                 'workerType': 'gecko-decision',
                 'provisionerId': 'aws-provisioner-v1',
+                'taskGroupId': task_group_id,
+                'schedulerId': 'gecko-level-{}'.format(parameters['level']),
                 'scopes': [
                     repo_scope,
                 ],
                 'tags': {
                     'createdForUser': parameters['owner'],
                     'kind': 'action-callback',
                 },
                 'routes': [
@@ -212,17 +217,17 @@ def register_callback_action(name, title
                 ],
                 'payload': {
                     'env': {
                         'GECKO_BASE_REPOSITORY': 'https://hg.mozilla.org/mozilla-unified',
                         'GECKO_HEAD_REPOSITORY': parameters['head_repository'],
                         'GECKO_HEAD_REF': parameters['head_ref'],
                         'GECKO_HEAD_REV': parameters['head_rev'],
                         'HG_STORE_PATH': '/home/worker/checkouts/hg-store',
-                        'ACTION_TASK_GROUP_ID': {'$eval': 'taskGroupId'},
+                        'ACTION_TASK_GROUP_ID': task_group_id,
                         'ACTION_TASK_ID': {'$json': {'$eval': 'taskId'}},
                         'ACTION_TASK': {'$json': {'$eval': 'task'}},
                         'ACTION_INPUT': {'$json': {'$eval': 'input'}},
                         'ACTION_CALLBACK': cb.__name__,
                         'ACTION_PARAMETERS': {'$json': {'$eval': 'parameters'}},
                     },
                     'cache': {
                         'level-{}-checkouts'.format(parameters['level']):