Bug 1338186 - assign bucket specific scopes per type of release. r=aki a=release DONTBUILD
authorMihai Tabara <mtabara@mozilla.com>
Fri, 24 Feb 2017 17:30:46 +0200
changeset 359482 3cdcc34a169397492a53242d2453bb76441ea0ea
parent 359481 06f4b5a254345560e932eaccc54ba5d5717167cb
child 359483 3163a9a12db6371be57c54362ea8d4ca1d083e04
push id10815
push usermtabara@mozilla.com
push dateMon, 27 Feb 2017 17:47:32 +0000
treeherdermozilla-aurora@3cdcc34a1693 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaki, release
bugs1338186
milestone53.0a2
Bug 1338186 - assign bucket specific scopes per type of release. r=aki a=release DONTBUILD MozReview-Commit-ID: 7OAIvkaFF2a
taskcluster/taskgraph/transforms/beetmover.py
taskcluster/taskgraph/transforms/beetmover_checksums.py
taskcluster/taskgraph/util/scriptworker.py
--- a/taskcluster/taskgraph/transforms/beetmover.py
+++ b/taskcluster/taskgraph/transforms/beetmover.py
@@ -4,17 +4,18 @@
 """
 Transform the beetmover task into an actual task description.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.base import TransformSequence
 from taskgraph.util.schema import validate_schema
-from taskgraph.util.scriptworker import get_beetmover_bucket_scope
+from taskgraph.util.scriptworker import (get_beetmover_bucket_scope,
+                                         get_beetmover_action_scope)
 from taskgraph.transforms.task import task_description_schema
 from voluptuous import Schema, Any, Required, Optional
 
 
 _DESKTOP_UPSTREAM_ARTIFACTS_UNSIGNED_EN_US = [
     "balrog_props.json",
     "target.common.tests.zip",
     "target.cppunittest.tests.zip",
@@ -196,23 +197,24 @@ def make_task_description(config, jobs):
             'nightly': dep_job.attributes.get('nightly', False),
             'build_platform': dep_job.attributes.get('build_platform'),
             'build_type': dep_job.attributes.get('build_type'),
         }
         if job.get('locale'):
             attributes['locale'] = job['locale']
 
         bucket_scope = get_beetmover_bucket_scope(config)
+        action_scope = get_beetmover_action_scope(config)
 
         task = {
             'label': label,
             'description': "{} Beetmover".format(
                 dep_job.task["metadata"]["description"]),
             'worker-type': 'scriptworker-prov-v1/beetmoverworker-v1',
-            'scopes': [bucket_scope],
+            'scopes': [bucket_scope, action_scope],
             'dependencies': dependencies,
             'attributes': attributes,
             'run-on-projects': dep_job.attributes.get('run_on_projects'),
             'treeherder': treeherder,
         }
 
         yield task
 
--- a/taskcluster/taskgraph/transforms/beetmover_checksums.py
+++ b/taskcluster/taskgraph/transforms/beetmover_checksums.py
@@ -4,17 +4,18 @@
 """
 Transform the checksums signing task into an actual task description.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.base import TransformSequence
 from taskgraph.util.schema import validate_schema
-from taskgraph.util.scriptworker import get_beetmover_bucket_scope
+from taskgraph.util.scriptworker import (get_beetmover_bucket_scope,
+                                         get_beetmover_action_scope)
 from taskgraph.transforms.task import task_description_schema
 from voluptuous import Schema, Any, Required, Optional
 
 # Voluptuous uses marker objects as dictionary *keys*, but they are not
 # comparable, so we cast all of the keys back to regular strings
 task_description_schema = {str(k): v for k, v in task_description_schema.schema.iteritems()}
 
 transforms = TransformSequence()
@@ -67,22 +68,24 @@ def make_beetmover_checksums_description
             'build_platform': dep_job.attributes.get('build_platform'),
             'build_type': dep_job.attributes.get('build_type'),
         }
         if dep_job.attributes.get('locale'):
             treeherder['symbol'] = 'tc-BMcs({})'.format(dep_job.attributes.get('locale'))
             attributes['locale'] = dep_job.attributes.get('locale')
 
         bucket_scope = get_beetmover_bucket_scope(config)
+        action_scope = get_beetmover_action_scope(config)
+
         task = {
             'label': label,
             'description': "Beetmover {} ".format(
                 dep_job.task["metadata"]["description"]),
             'worker-type': 'scriptworker-prov-v1/beetmoverworker-v1',
-            'scopes': [bucket_scope],
+            'scopes': [bucket_scope, action_scope],
             'dependencies': dependencies,
             'attributes': attributes,
             'run-on-projects': dep_job.attributes.get('run_on_projects'),
             'treeherder': treeherder,
         }
 
         yield task
 
--- a/taskcluster/taskgraph/util/scriptworker.py
+++ b/taskcluster/taskgraph/util/scriptworker.py
@@ -49,24 +49,48 @@ SIGNING_CERT_SCOPES = {
 }
 
 """Map beetmover scope aliases to sets of projects.
 
 Currently this mirrors the signing scope alias behavior.
 """
 BEETMOVER_SCOPE_ALIAS_TO_PROJECT = deepcopy(SIGNING_SCOPE_ALIAS_TO_PROJECT)
 
+"""Map beetmover tasks aliases to sets of target task methods.
+
+This is a list of list-pairs, for ordering.
+"""
+BEETMOVER_SCOPE_ALIAS_TO_TARGET_TASK = [[
+    'all-nightly-tasks', set([
+        'nightly_fennec',
+        'nightly_linux',
+    ])
+], [
+    'all-release-tasks', set([
+        'mozilla_beta_tasks',
+        'mozilla_release_tasks',
+    ])
+]]
+
 """Map the beetmover scope aliases to the actual scopes.
 """
 BEETMOVER_BUCKET_SCOPES = {
     'all-release-branches': 'project:releng:beetmover:nightly',
     'all-nightly-branches': 'project:releng:beetmover:nightly',
     'default': 'project:releng:beetmover:nightly',
 }
 
+"""Map the beetmover tasks aliases to the actual action scopes.
+"""
+BEETMOVER_ACTION_SCOPES = {
+    'all-release-tasks': 'project:releng:beetmover:action:push-to-candidates',
+    'all-nightly-tasks': 'project:releng:beetmover:action:push-to-nightly',
+    'default': 'project:releng:beetmover:action:push-to-staging',
+}
+
 """Map balrog scope aliases to sets of projects.
 
 This is a list of list-pairs, for ordering.
 """
 BALROG_SCOPE_ALIAS_TO_PROJECT = [[
     'nightly', set([
         'mozilla-central',
     ])
@@ -108,25 +132,49 @@ def get_scope_from_project(alias_to_proj
         string: the scope to use.
     """
     for alias, projects in alias_to_project_map:
         if config.params['project'] in projects and alias in alias_to_scope_map:
             return alias_to_scope_map[alias]
     return alias_to_scope_map['default']
 
 
+def get_scope_from_target_method(alias_to_tasks_map, alias_to_scope_map, config):
+    """Determine the restricted scope from `config.params['target_tasks_method']`.
+
+    Args:
+        alias_to_tasks_map (list of lists): each list pair contains the
+            alias alias and the set of target methods that match. This is ordered.
+        alias_to_scope_map (dict): the alias alias to scope
+        config (dict): the task config that defines the target task method.
+
+    Returns:
+        string: the scope to use.
+    """
+    for alias, tasks in alias_to_tasks_map:
+        if config.params['target_tasks_method'] in tasks and alias in alias_to_scope_map:
+            return alias_to_scope_map[alias]
+    return alias_to_scope_map['default']
+
+
 get_signing_cert_scope = functools.partial(
     get_scope_from_project,
     SIGNING_SCOPE_ALIAS_TO_PROJECT,
     SIGNING_CERT_SCOPES
 )
 
 get_beetmover_bucket_scope = functools.partial(
     get_scope_from_project,
     BEETMOVER_SCOPE_ALIAS_TO_PROJECT,
     BEETMOVER_BUCKET_SCOPES
 )
 
+get_beetmover_action_scope = functools.partial(
+    get_scope_from_target_method,
+    BEETMOVER_SCOPE_ALIAS_TO_TARGET_TASK,
+    BEETMOVER_ACTION_SCOPES
+)
+
 get_balrog_server_scope = functools.partial(
     get_scope_from_project,
     BALROG_SCOPE_ALIAS_TO_PROJECT,
     BALROG_SERVER_SCOPES
 )