Bug 1450012: [taskgraph] Add an action to retirgger multiple tasks at once; r=dustin
authorTom Prince <mozilla@hocat.ca>
Mon, 15 Apr 2019 20:21:30 +0000
changeset 526532 bb082e4ef0d4431d8f4edebd436d2063835c5873
parent 526531 8667f041f6c2f7adffabe2d0e65ef0dfd39c3944
child 526533 4649dbd1d133e1900e3232724aec002ce3dd2655
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1450012, 1519599, 1521032
milestone67.0
Bug 1450012: [taskgraph] Add an action to retirgger multiple tasks at once; r=dustin In Bug 1519599, treeherder switched to using add-new-jobs to retrigger jobs, since there wasn't an action to retrigger multiple jobs. This prevents us from adding logic to rerun some jobs instead of retriggering them. This adds a new action that takes input like `add-new-jobs`, but that we can add logic to handle rerun vs. retrigger in. Additionally, the input it takes is designed to make Bug 1521032 easier to implement. Differential Revision: https://phabricator.services.mozilla.com/D27207
taskcluster/taskgraph/actions/retrigger.py
--- a/taskcluster/taskgraph/actions/retrigger.py
+++ b/taskcluster/taskgraph/actions/retrigger.py
@@ -201,8 +201,67 @@ def rerun_action(parameters, graph_confi
     status = taskcluster.status_task(task_id)
     if status not in RERUN_STATES:
         logger.warning(
             "No need to to rerun {}: state '{}' not in {}!".format(label, status, RERUN_STATES)
         )
         return
     taskcluster.rerun_task(task_id)
     logger.info('Reran {}'.format(label))
+
+
+@register_callback_action(
+    title='Retrigger',
+    name='retrigger-multiple',
+    symbol='rt',
+    generic=True,
+    description=(
+        'Create a clone of the task.'
+    ),
+    context=[],
+    schema={
+        "type": "object",
+        "properties": {
+            "requests": {
+                "type": "array",
+                "items": {
+                    "tasks": {
+                        "type": "array",
+                        'description': 'An array of task labels',
+                        'items': {
+                            'type': 'string'
+                        }
+                    },
+                    "times": {
+                        "type": "integer",
+                        "minimum": 1,
+                        "maximum": 100,
+                        "title": "Times",
+                        "description": "How many times to run each task.",
+                    },
+                    "additionalProperties": False,
+                },
+            },
+            "additionalProperties": False,
+        },
+    },
+)
+def retrigger_multiple(parameters, graph_config, input, task_group_id, task_id):
+    decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
+        parameters, graph_config)
+
+    suffixes = []
+    for i, request in enumerate(input.get('requests', [])):
+        times = request.get('times', 1)
+        for j in xrange(times):
+            suffix = '{}-{}'.format(i, j)
+            suffixes.append(suffix)
+            create_tasks(
+                graph_config,
+                request.get('tasks'),
+                full_task_graph,
+                label_to_taskid,
+                parameters,
+                decision_task_id,
+                suffix,
+            )
+
+    combine_task_graph_files(suffixes)