Bug 1380123 - mitigate duplicate nightly graphs off the same revision. r=taskgraph-reviewers,jmaher

We can still get multiple nightly graphs off the same revision, if
the 2nd cron task runs before the 1st one finishes. However, once
the 1st finishes, we will prevent a 2nd nightly graph. (This has the
side effect of not being able to trigger a 2nd nightly graph off the
same revision, even if the first nightly graph failed, but I think
that's still an improvement. We can work around this with a new push,
or triggering the platform-specific nightly graphs.)

Differential Revision: https://phabricator.services.mozilla.com/D118543
This commit is contained in:
Aki Sasaki
2021-06-23 02:38:18 +00:00
parent 341f5756c1
commit 0052139a2b

View File

@@ -7,13 +7,16 @@
from __future__ import absolute_import, print_function, unicode_literals
import copy
import os
import re
import six
from redo import retry
from taskgraph import try_option_syntax
from taskgraph.parameters import Parameters
from taskgraph.util.attributes import match_run_on_projects, match_run_on_hg_branches
from taskgraph.util.platforms import platform_family
from taskgraph.util.taskcluster import find_task_id
_target_task_methods = {}
@@ -57,6 +60,17 @@ def get_method(method):
return _target_task_methods[method]
def index_exists(index_path, reason=""):
print(f"Looking for existing index {index_path} {reason}...")
try:
task_id = find_task_id(index_path)
print(f"Index {index_path} exists: taskId {task_id}")
return True
except KeyError:
print(f"Index {index_path} doesn't exist.")
return False
def filter_out_shipping_phase(task, parameters):
return (
# nightly still here because of geckodriver
@@ -908,6 +922,19 @@ def target_tasks_daily_releases(full_task_graph, parameters, graph_config):
def target_tasks_nightly_desktop(full_task_graph, parameters, graph_config):
"""Select the set of tasks required for a nightly build of linux, mac,
windows."""
index_path = (
f"{graph_config['trust-domain']}.v2.{parameters['project']}.revision."
f"{parameters['head_rev']}.taskgraph.decision-nightly-desktop"
)
if os.environ.get("MOZ_AUTOMATION") and retry(
index_exists,
args=(index_path,),
kwargs={
"reason": "to avoid triggering multiple nightlies off the same revision",
},
):
return []
# Tasks that aren't platform specific
release_filter = make_desktop_nightly_filter({None})
release_tasks = [