Bug 1524358 - use ownTaskId, instead of as_slugid('decision'), in .taskcluster.yml r=Callek,tomprince
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 01 Feb 2019 23:27:47 +0000
changeset 514501 7fb53ad56f8539f82f0d0cee4124a4e4847e796f
parent 514500 b7a0772936d3608c5e34a0f11f56345962192c01
child 514502 5b3dfdf7012637dbe652898d1e5d35dd99905b64
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek, tomprince
bugs1524358
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524358 - use ownTaskId, instead of as_slugid('decision'), in .taskcluster.yml r=Callek,tomprince 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}"
@@ -132,17 +133,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}'
                 # BUG 1500166 Notify ciduty by email if a nightly hook fails
                 - "notify.email.ciduty+failedcron@mozilla.com.on-failed"
                 - "notify.email.ciduty+exceptioncron@mozilla.com.on-exception"
                 - "notify.email.sheriffs+failedcron@mozilla.org.on-failed"
                 - "notify.email.sheriffs+exceptioncron@mozilla.org.on-exception"
                 # These are the old index routes for the decision task.
                 - "index.gecko.v2.${repository.project}.latest.firefox.decision-${cron.job_name}"
 
--- a/taskcluster/taskgraph/cron/decision.py
+++ b/taskcluster/taskgraph/cron/decision.py
@@ -38,25 +38,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'],
@@ -73,17 +64,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')