Bug 1302804 - Ensure that tasks in a taskgraph do not have duplicate gecko.v2 routes; r?dustin
MozReview-Commit-ID: B4Ok4WhqBVq
--- a/taskcluster/taskgraph/generator.py
+++ b/taskcluster/taskgraph/generator.py
@@ -7,17 +7,21 @@ import logging
import os
import yaml
from . import filter_tasks
from .graph import Graph
from .taskgraph import TaskGraph
from .optimize import optimize_task_graph
from .util.python_path import find_object
-from .util.verify import verify_docs, verify_task_graph_symbol
+from .util.verify import (
+ verify_docs,
+ verify_task_graph_symbol,
+ verify_gecko_v2_routes,
+)
logger = logging.getLogger(__name__)
class Kind(object):
def __init__(self, name, path, config):
self.name = name
@@ -213,16 +217,17 @@ class TaskGraphGenerator(object):
yield 'target_task_set', target_task_set
logger.info("Generating target task graph")
target_graph = full_task_graph.graph.transitive_closure(target_tasks)
target_task_graph = TaskGraph(
{l: all_tasks[l] for l in target_graph.nodes},
target_graph)
target_task_graph.for_each_task(verify_task_graph_symbol, scratch_pad={})
+ target_task_graph.for_each_task(verify_gecko_v2_routes, scratch_pad={})
yield 'target_task_graph', target_task_graph
logger.info("Generating optimized task graph")
do_not_optimize = set()
if not self.parameters.get('optimize_target_tasks', True):
do_not_optimize = target_task_set.graph.nodes
optimized_task_graph, label_to_taskid = optimize_task_graph(target_task_graph,
--- a/taskcluster/taskgraph/util/verify.py
+++ b/taskcluster/taskgraph/util/verify.py
@@ -60,8 +60,28 @@ def verify_task_graph_symbol(task, taskg
key = (collection_keys, platform, group_symbol, symbol)
if key in scratch_pad:
raise Exception(
"conflict between `{}`:`{}` for values `{}`"
.format(task.label, scratch_pad[key], key)
)
else:
scratch_pad[key] = task.label
+
+
+def verify_gecko_v2_routes(task, taskgraph, scratch_pad):
+ """
+ This function ensures that any two
+ tasks have distinct index.v2.routes
+ """
+ route_prefix = "index.gecko.v2"
+ task_dict = task.task
+ routes = task_dict.get('routes', [])
+
+ for route in routes:
+ if route.startswith(route_prefix):
+ if route in scratch_pad:
+ raise Exception(
+ "conflict between {}:{} for route: {}"
+ .format(task.label, scratch_pad[route], route)
+ )
+ else:
+ scratch_pad[route] = task.label