Bug 1524358 - Use ownTaskId, instead of as_slugid('decision'), in .taskcluster.yml. r=Callek,tomprince, a=RyanVM
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 01 Feb 2019 23:27:47 +0000
changeset 509607 ad0d9539cc64f1feddf6f9651017b21b78b422fb
parent 509606 bbc3115c907766a8cc93b81f418731385d58df6b
child 509608 b04e2261e4c9f3616e18184e4fa7e25997f5b56e
push id1927
push userryanvm@gmail.com
push dateTue, 05 Feb 2019 18:23:21 +0000
treeherdermozilla-release@b04e2261e4c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek, tomprince, RyanVM
bugs1524358
milestone65.0.1
Bug 1524358 - Use ownTaskId, instead of as_slugid('decision'), in .taskcluster.yml. r=Callek,tomprince, a=RyanVM This is a forward-looking change to allow evaluation of .taskcluster.yml in situations where as_slugid is not defined -- such as in the Taskcluster hooks service. Differential Revision: https://phabricator.services.mozilla.com/D18269
.taskcluster.yml
taskcluster/taskgraph/cron/decision.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -2,26 +2,27 @@
 # - mozilla-taskcluster - See
 #   https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml
 #   {
 #     tasks_for: 'hg-push',
 #     push: {owner, comment, pushlog_id, pushdate},
 #     repository: {url, project, level},
 #     now,
 #     as_slugid: // function
+#     ownTaskId: // taskId of the task that will be created
 #   }
 #
 # - cron tasks - See taskcluster/taskgraph/cron/decision.py
 #   {
 #     tasks_for: 'cron',
 #     push: {revision, pushlog_id, pushdate, owner, comment}
 #     repository: {url, project, level},
 #     cron: {task_id, job_name, job_symbol, quoted_args},
 #     now,
-#     as_slugid, // function
+#     ownTaskId: // taskId of the task that will be created
 #   }
 #
 # - action tasks - See:
 #   * taskcluster/taskgraph/actions/registry.py,
 #   * https://docs.taskcluster.net/docs/manual/using/actions/spec
 #   * ci-admin:ciadmin/generate/in_tree_actions.py
 #
 #   The registry generates the hookPayload that appears in actions.json, and
@@ -53,23 +54,23 @@ tasks:
   - $if: 'tasks_for in ["hg-push", "action", "cron"]'
     then:
       $let:
         # sometimes the push user is just `ffxbld` or the like, but we want an email-like field..
         ownerEmail: {$if: '"@" in push.owner', then: '${push.owner}', else: '${push.owner}@noreply.mozilla.org'}
         # ensure there's no trailing `/` on the repo URL
         repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}}
       in:
-        taskId: {$if: 'tasks_for != "action"', then: '${as_slugid("decision")}'}
+        taskId: {$if: 'tasks_for != "action"', then: '${ownTaskId}'}
         taskGroupId:
           $if: 'tasks_for == "action"'
           then:
             '${action.taskGroupId}'
           else:
-            '${as_slugid("decision")}' # same as taskId; this is how automation identifies a decision tsak
+            '${ownTaskId}' # same as taskId; this is how automation identifies a decision tsak
         schedulerId: 'gecko-level-${repository.level}'
 
         created: {$fromNow: ''}
         deadline: {$fromNow: '1 day'}
         expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors
         metadata:
           $merge:
             - owner: "${ownerEmail}"
@@ -134,17 +135,17 @@ tasks:
                 - "notify.email.taskcluster-notifications+action-task@mozilla.com.on-failed"
                 - "notify.email.taskcluster-notifications+action-task@mozilla.com.on-exception"
                 - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.actions.${ownTaskId}"
                 else:  # cron
                 - "index.gecko.v2.${repository.project}.latest.taskgraph.decision-${cron.job_name}"
                 - "index.gecko.v2.${repository.project}.revision.${push.revision}.taskgraph.decision-${cron.job_name}"
                 - "index.gecko.v2.${repository.project}.pushlog-id.${push.pushlog_id}.decision-${cron.job_name}"
                 # list each cron task on this revision, so actions can find them
-                - 'index.gecko.v2.${repository.project}.revision.${push.revision}.cron.${as_slugid("decision")}'
+                - 'index.gecko.v2.${repository.project}.revision.${push.revision}.cron.${ownTaskId}'
                 # These are the old index routes for the decision task.
                 - "index.gecko.v2.${repository.project}.latest.firefox.decision-${cron.job_name}"
 
         scopes:
           $if: 'tasks_for == "hg-push"'
           then:
             - 'assume:repo:${repoUrl[8:]}:branch:default'
             - 'queue:route:notify.email.${ownerEmail}.*'
--- a/taskcluster/taskgraph/cron/decision.py
+++ b/taskcluster/taskgraph/cron/decision.py
@@ -34,25 +34,16 @@ def make_decision_task(params, root, sym
     """Generate a basic decision task, based on the root .taskcluster.yml"""
     with open(os.path.join(root, '.taskcluster.yml'), 'rb') as f:
         taskcluster_yml = yaml.safe_load(f)
 
     push_info = find_hg_revision_push_info(
         params['repository_url'],
         params['head_rev'])
 
-    slugids = {}
-
-    def as_slugid(name):
-        # https://github.com/taskcluster/json-e/issues/164
-        name = name[0]
-        if name not in slugids:
-            slugids[name] = slugid.nice()
-        return slugids[name]
-
     # provide a similar JSON-e context to what mozilla-taskcluster provides:
     # https://docs.taskcluster.net/reference/integrations/mozilla-taskcluster/docs/taskcluster-yml
     # but with a different tasks_for and an extra `cron` section
     context = {
         'tasks_for': 'cron',
         'repository': {
             'url': params['repository_url'],
             'project': params['project'],
@@ -69,17 +60,17 @@ def make_decision_task(params, root, sym
         'cron': {
             'task_id': os.environ.get('TASK_ID', '<cron task id>'),
             'job_name': params['job_name'],
             'job_symbol': symbol,
             # args are shell-quoted since they are given to `bash -c`
             'quoted_args': ' '.join(pipes.quote(a) for a in arguments),
         },
         'now': current_json_time(),
-        'as_slugid': as_slugid,
+        'ownTaskId': slugid.nice(),
     }
 
     rendered = jsone.render(taskcluster_yml, context)
     if len(rendered['tasks']) != 1:
         raise Exception("Expected .taskcluster.yml to only produce one cron task")
     task = rendered['tasks'][0]
 
     task_id = task.pop('taskId')