Files
Julien Cristau dc1a0c89a1 Bug 1856897 - fix rerun actions in the presence of multiple tasks with the same label. r=taskgraph-reviewers,releng-reviewers,bhearsum
`fetch_graph_and_labels` grabs the `label_to_taskid` mapping from the original
decision task plus any action and cron tasks on the same revision.  In that
process it only keeps track of one task id per label (whichever it sees last).

In most cases that's not a big deal, but there's a couple of instances where it
matters:

- the `rerun` action checks that the input task id is part of the mapping, and
  doesn't do anything if it is not, so won't rerun a task that was part of the
  initial graph and whose label was re-used later (e.g. from a retrigger)
- the `retrigger-multiple` action checks to see if a label should be rerun
  instead, and in that case uses the label_to_taskid mapping to decide which
  exact task to rerun.  Again if there's more than one task on that revision
  with the same label (e.g. from a forced retrigger or cron), it might not pick
  the expected one.

Fix this by having `fetch_graph_and_labels` also return a `label_to_taskids`
mapping.  The `rerun` action's check now looks for the task id there instead of
the incomplete `label_to_taskid`, and `retrigger-multiple` attempts to rerun
all tasks with the given label instead of just one.

Differential Revision: https://phabricator.services.mozilla.com/D194600
2023-11-30 13:48:17 +00:00

60 lines
1.7 KiB
Python

# 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/.
import logging
from ..target_tasks import standard_filter
from .registry import register_callback_action
from .util import create_tasks, fetch_graph_and_labels
logger = logging.getLogger(__name__)
@register_callback_action(
name="run-all-talos",
title="Run All Talos Tests",
symbol="raT",
description="Add all Talos tasks to a push.",
order=150,
context=[],
schema={
"type": "object",
"properties": {
"times": {
"type": "integer",
"default": 1,
"minimum": 1,
"maximum": 6,
"title": "Times",
"description": "How many times to run each task.",
}
},
"additionalProperties": False,
},
)
def add_all_talos(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
)
times = input.get("times", 1)
for i in range(times):
to_run = [
label
for label, entry in full_task_graph.tasks.items()
if "talos_try_name" in entry.attributes
and standard_filter(entry, parameters)
]
create_tasks(
graph_config,
to_run,
full_task_graph,
label_to_taskid,
parameters,
decision_task_id,
)
logger.info(f"Scheduled {len(to_run)} talos tasks (time {i + 1}/{times})")