# 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 requests import HTTPError from taskgraph.util.taskcluster import find_task_id, get_artifact
from gecko_taskgraph.util.attributes import INTEGRATION_PROJECTS, TRY_PROJECTS from gecko_taskgraph.util.taskcluster import state_task
def is_backstop(
params,
push_interval=BACKSTOP_PUSH_INTERVAL,
time_interval=BACKSTOP_TIME_INTERVAL,
trust_domain="gecko",
integration_projects=INTEGRATION_PROJECTS,
backstop_strategy="backstop",
): """Determines whether the given parameters represent a backstop push.
Args:
push_interval (int): Number of pushes
time_interval (int): Minutes between forced schedules.
Use 0 to disable.
trust_domain (str): "gecko"for Firefox, "comm"for Thunderbird
integration_projects (set): project that uses backstop optimization
Returns:
bool: Trueif this is a backstop, otherwise False. """ # In case this is being faked on try. if params.get(backstop_strategy, False): returnTrue
project = params["project"] if project in TRY_PROJECTS: returnFalse if project notin integration_projects: returnTrue
# This push was explicitly set to run nothing (e.g via DONTBUILD), so # shouldn't be a backstop candidate. if params["target_tasks_method"] == "nothing": returnFalse
# Find the last backstop to compute push and time intervals.
subs = {"trust-domain": trust_domain, "project": project}
index = STRATEGY_TO_INDEX_MAP[backstop_strategy].format(**subs)
try:
last_backstop_id = find_task_id(index) except KeyError: # Index wasn't found, implying there hasn't been a backstop push yet. returnTrue
if state_task(last_backstop_id) in ("failed", "exception"): # If the last backstop failed its decision task, make this a backstop. returnTrue
try:
last_params = get_artifact(last_backstop_id, "public/parameters.yml") except HTTPError as e: # If the last backstop decision task exists in the index, but # parameters.yml isn't available yet, it means the decision task is # still running. If that's the case, we can be pretty sure the time # component will not cause a backstop, so just return False. if e.response.status_code == 404: returnFalse raise
# On every Nth push, want to run all tasks. if int(params["pushlog_id"]) - int(last_params["pushlog_id"]) >= push_interval: returnTrue
if time_interval <= 0: returnFalse
# We also want to ensure we run all tasks at least once per N minutes. if (params["pushdate"] - last_params["pushdate"]) / 60 >= time_interval: returnTrue
returnFalse
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.