From 0bdcc1c550d9b743c2302e8ed92ea7f16320d955 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 12 Dec 2019 02:35:18 +0000 Subject: [PATCH] Bug 1554771: Allow reruning tasks not in the full task graph from treeherder; r=Callek Rerunning via action (i.e. from treeherder) currently fails for partials, as the task isn't in the full task graph (since the parameters for the push-task don't have the partials). Since (at least currently) all tasks not in the full graph are release tasks, assume that they require reruns, not retriggers, to allow easier handling of tasks via treeherder. Differential Revision: https://phabricator.services.mozilla.com/D56516 --HG-- extra : moz-landing-system : lando --- taskcluster/taskgraph/actions/retrigger.py | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/taskcluster/taskgraph/actions/retrigger.py b/taskcluster/taskgraph/actions/retrigger.py index d2713cdc44c9..d90c9d68031d 100644 --- a/taskcluster/taskgraph/actions/retrigger.py +++ b/taskcluster/taskgraph/actions/retrigger.py @@ -27,6 +27,22 @@ logger = logging.getLogger(__name__) RERUN_STATES = ('exception', 'failed') +def _should_retrigger(task_graph, label): + """ + Return whether a given task in the taskgraph should be retriggered. + + This handles the case where the task isn't there by assuming it should not be. + """ + if label not in task_graph: + logger.info( + "Task {} not in full taskgraph, assuming task should not be retriggered.".format( + label + ) + ) + return False + return task_graph[label].attributes.get("retrigger", False) + + @register_callback_action( title='Retrigger', name='retrigger', @@ -138,7 +154,7 @@ def retrigger_action(parameters, graph_config, input, task_group_id, task_id): with_downstream = ' ' to_run = [label] - if not input.get('force', None) and not full_task_graph[label].attributes.get('retrigger'): + if not input.get('force', None) and not _should_retrigger(full_task_graph, label): logger.info( "Not retriggering task {}, task should not be retrigged " "and force not specified.".format( @@ -257,10 +273,11 @@ def retrigger_multiple(parameters, graph_config, input, task_group_id, task_id): times = request.get('times', 1) rerun_tasks = [ label for label in request.get('tasks') - if not full_task_graph[label].attributes.get('retrigger')] + if not _should_retrigger(full_task_graph, label) + ] retrigger_tasks = [ label for label in request.get('tasks') - if full_task_graph[label].attributes.get('retrigger') + if _should_retrigger(full_task_graph, label) ] for label in rerun_tasks: