Bug 1450012: [taskgraph] Move rerun action to retrigger.py; r=dustin
authorTom Prince <mozilla@hocat.ca>
Mon, 15 Apr 2019 20:21:19 +0000
changeset 469729 acfc18211ade
parent 469728 3ff550948499
child 469730 fe831ef6691f
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
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] Move rerun action to retrigger.py; r=dustin In order to prevent retriggers for release tasks, we will cause the `retrigger` action to rerun instead, so move the cdoe togehter. Differential Revision: https://phabricator.services.mozilla.com/D27205
taskcluster/taskgraph/actions/rerun.py
taskcluster/taskgraph/actions/retrigger.py
deleted file mode 100644
--- a/taskcluster/taskgraph/actions/rerun.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from __future__ import absolute_import, print_function, unicode_literals
-
-import logging
-
-from taskgraph.util.taskcluster import (
-    status_task,
-    rerun_task
-)
-from .registry import register_callback_action
-from .util import fetch_graph_and_labels
-from taskgraph.util import taskcluster
-
-logger = logging.getLogger(__name__)
-
-RERUN_STATES = ('exception', 'failed')
-
-
-@register_callback_action(
-    title='Rerun',
-    name='rerun',
-    generic=True,
-    symbol='rr',
-    description=(
-        'Rerun a task.\n\n'
-        'This only works on failed or exception tasks in the original taskgraph,'
-        ' and is CoT friendly.'
-    ),
-    order=300,
-    context=[{}],
-    schema={
-        'type': 'object',
-        'properties': {}
-    }
-)
-def rerun_action(parameters, graph_config, input, task_group_id, task_id):
-    task = taskcluster.get_task_definition(task_id)
-    parameters = dict(parameters)
-    decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
-        parameters, graph_config)
-    label = task['metadata']['name']
-    if task_id not in label_to_taskid.values():
-        logger.error(
-            "Refusing to rerun {}: taskId {} not in decision task {} label_to_taskid!".format(
-                label, task_id, decision_task_id
-            )
-        )
-
-    status = 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
-    rerun_task(task_id)
-    logger.info('Reran {}'.format(label))
--- a/taskcluster/taskgraph/actions/retrigger.py
+++ b/taskcluster/taskgraph/actions/retrigger.py
@@ -17,16 +17,18 @@ from .util import (
     relativize_datestamps,
     create_task_from_def,
 )
 from .registry import register_callback_action
 from taskgraph.util import taskcluster
 
 logger = logging.getLogger(__name__)
 
+RERUN_STATES = ('exception', 'failed')
+
 
 @register_callback_action(
     title='Retrigger',
     name='retrigger',
     symbol='rt',
     cb_name='retrigger-decision',
     description=textwrap.dedent('''\
         Create a clone of the task (retriggering decision, action, and cron tasks requires
@@ -106,8 +108,48 @@ def retrigger_action(parameters, graph_c
             label_to_taskid,
             parameters,
             decision_task_id,
             i,
         )
 
         logger.info('Scheduled {}{}(time {}/{})'.format(label, with_downstream, i+1, times))
     combine_task_graph_files(list(range(times)))
+
+
+@register_callback_action(
+    title='Rerun',
+    name='rerun',
+    generic=True,
+    symbol='rr',
+    description=(
+        'Rerun a task.\n\n'
+        'This only works on failed or exception tasks in the original taskgraph,'
+        ' and is CoT friendly.'
+    ),
+    order=300,
+    context=[{}],
+    schema={
+        'type': 'object',
+        'properties': {}
+    }
+)
+def rerun_action(parameters, graph_config, input, task_group_id, task_id):
+    task = taskcluster.get_task_definition(task_id)
+    parameters = dict(parameters)
+    decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
+        parameters, graph_config)
+    label = task['metadata']['name']
+    if task_id not in label_to_taskid.values():
+        logger.error(
+            "Refusing to rerun {}: taskId {} not in decision task {} label_to_taskid!".format(
+                label, task_id, decision_task_id
+            )
+        )
+
+    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))