Bug 1415868 - remove ACTION_TASK draft
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 27 Apr 2018 22:24:42 +0000
changeset 797831 f09a71f2b27affb6f5c22d1bcde36a387c7dfae7
parent 797332 1ebe5befd1964018d1ec46c6e7c28a1bb84e5da4
child 797832 03fd49fbf6d1d117e98ffbb2e95303917a45294c
push id110591
push userdmitchell@mozilla.com
push dateMon, 21 May 2018 19:46:43 +0000
bugs1415868
milestone62.0a1
Bug 1415868 - remove ACTION_TASK For kind=hook, the spec doesn't include this value as it's untrustworthy. For kind=task, it's still untrustworthy, but there is no privilege escalation so that's not important. Still, it dramatically expands the size of the task definition. MozReview-Commit-ID: 6scQ2ZwxP10
.taskcluster.yml
taskcluster/mach_commands.py
taskcluster/taskgraph/actions/registry.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -103,17 +103,16 @@ tasks:
               GECKO_HEAD_REV: '${push.revision}'
               GECKO_COMMIT_MSG: {$if: 'tasks_for != "action"', then: '${push.comment}'}
               HG_STORE_PATH: /builds/worker/checkouts/hg-store
               TASKCLUSTER_CACHES: /builds/worker/checkouts
             - $if: 'tasks_for == "action"'
               then:
                 ACTION_TASK_GROUP_ID: '${ownTaskId}'
                 ACTION_TASK_ID: {$json: {$eval: 'taskId'}}
-                ACTION_TASK: {$json: {$eval: 'task'}}
                 ACTION_INPUT: {$json: {$eval: 'input'}}
                 ACTION_CALLBACK: '${action.cb_name}'
                 ACTION_PARAMETERS: {$json: {$eval: 'parameters'}}
 
         cache:
           level-${repository.level}-checkouts-sparse-v2: /builds/worker/checkouts
 
         features:
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -230,26 +230,24 @@ class MachCommands(MachCommandBase):
                      help="root of the taskgraph definition relative to topsrcdir")
     def action_callback(self, **options):
         import taskgraph.actions
         try:
             self.setup_logging()
 
             task_group_id = os.environ.get('ACTION_TASK_GROUP_ID', None)
             task_id = json.loads(os.environ.get('ACTION_TASK_ID', 'null'))
-            task = json.loads(os.environ.get('ACTION_TASK', 'null'))
             input = json.loads(os.environ.get('ACTION_INPUT', 'null'))
             callback = os.environ.get('ACTION_CALLBACK', None)
             parameters = json.loads(os.environ.get('ACTION_PARAMETERS', '{}'))
             root = options['root']
 
             return taskgraph.actions.trigger_action_callback(
                     task_group_id=task_group_id,
                     task_id=task_id,
-                    task=task,
                     input=input,
                     callback=callback,
                     parameters=parameters,
                     root=root,
                     test=False)
         except Exception:
             traceback.print_exc()
             sys.exit(1)
--- a/taskcluster/taskgraph/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -213,17 +213,16 @@ def register_callback_action(name, title
                             'push': push,
                             # parameters is long, so fetch it from the actions.json variables
                             'parameters': {'$eval': 'parameters'},
                         },
 
                         # and pass everything else through from our own context
                         "user": {
                             'input': {'$eval': 'input'},
-                            'task': {'$eval': 'task'},
                             'taskId': {'$eval': 'taskId'},
                             'taskGroupId': {'$eval': 'taskGroupId'},
                         }
                     },
                 })
 
             return rv
 
@@ -259,33 +258,39 @@ def render_actions_json(parameters, grap
         'version': 1,
         'variables': {
             'parameters': dict(**parameters),
         },
         'actions': actions,
     }
 
 
-def trigger_action_callback(task_group_id, task_id, task, input, callback, parameters, root,
+def trigger_action_callback(task_group_id, task_id, input, callback, parameters, root,
                             test=False):
     """
     Trigger action callback with the given inputs. If `test` is true, then run
     the action callback in testing mode, without actually creating tasks.
     """
     graph_config = load_graph_config(root)
     callbacks = _get_callbacks(graph_config)
     cb = callbacks.get(callback, None)
     if not cb:
         raise Exception('Unknown callback: {}. Known callbacks: {}'.format(
             callback, callbacks))
 
     if test:
         create.testing = True
         taskcluster.testing = True
 
+    # fetch the task, if taskId was given
+    # FIXME: many actions don't need this, so move this fetch into the callbacks
+    # that do need it
+    if task_id:
+        task = taskcluster.get_task_definition(task_id)
+
     cb(Parameters(**parameters), graph_config, input, task_group_id, task_id, task)
 
 
 def _load(graph_config):
     # Load all modules from this folder, relying on the side-effects of register_
     # functions to populate the action registry.
     actions_dir = os.path.dirname(__file__)
     for f in os.listdir(actions_dir):