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 469731 43956eb12043
parent 469730 fe831ef6691f
child 469732 c33e7bb2397c
push id35880
push usercbrindusan@mozilla.com
push dateWed, 17 Apr 2019 09:36:19 +0000
treeherdermozilla-central@79e6ed0b08d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1450012, 1519599, 1521032
milestone68.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 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)