Bug 1302227: set the taskGroupId to match the decision task; r=garndt

In this case, the tasks must have the same schedulerId as the existing task,
so this is calculated using parameters['level'].

MozReview-Commit-ID: G8EE2kvFstT

--HG--
extra : rebase_source : 214885da9b58520727d5f80b9a31bb8a206f9279
This commit is contained in:
Dustin J. Mitchell 2016-09-22 21:30:56 +00:00
parent cd6c2e6bff
commit 1045a329b8
3 changed files with 13 additions and 7 deletions

View File

@ -23,9 +23,7 @@ logger = logging.getLogger(__name__)
CONCURRENCY = 50
def create_tasks(taskgraph, label_to_taskid):
# TODO: use the taskGroupId of the decision task
task_group_id = slugid()
def create_tasks(taskgraph, label_to_taskid, params):
taskid_to_label = {t: l for l, t in label_to_taskid.iteritems()}
session = requests.Session()
@ -40,6 +38,13 @@ def create_tasks(taskgraph, label_to_taskid):
decision_task_id = os.environ.get('TASK_ID')
# when running as an actual decision task, we use the decision task's
# taskId as the taskGroupId. The process that created the decision task
# helpfully placed it in this same taskGroup. If there is no $TASK_ID,
# fall back to a slugid
task_group_id = decision_task_id or slugid()
scheduler_id = 'gecko-level-{}'.format(params['level'])
with futures.ThreadPoolExecutor(CONCURRENCY) as e:
fs = {}
@ -62,7 +67,7 @@ def create_tasks(taskgraph, label_to_taskid):
task_def['dependencies'] = [decision_task_id]
task_def['taskGroupId'] = task_group_id
task_def['schedulerId'] = '-'
task_def['schedulerId'] = scheduler_id
# Wait for dependencies before submitting this.
deps_fs = [fs[dep] for dep in task_def.get('dependencies', [])

View File

@ -91,7 +91,7 @@ def taskgraph_decision(options):
write_artifact('label-to-taskid.json', tgg.label_to_taskid)
# actually create the graph
create_tasks(tgg.optimized_task_graph, tgg.label_to_taskid)
create_tasks(tgg.optimized_task_graph, tgg.label_to_taskid, parameters)
def get_decision_parameters(options):

View File

@ -44,10 +44,11 @@ class TestCreate(unittest.TestCase):
graph = Graph(nodes={'tid-a', 'tid-b'}, edges={('tid-a', 'tid-b', 'edge')})
taskgraph = TaskGraph(tasks, graph)
create.create_tasks(taskgraph, label_to_taskid)
create.create_tasks(taskgraph, label_to_taskid, {'level': '4'})
for tid, task in self.created_tasks.iteritems():
self.assertEqual(task['payload'], 'hello world')
self.assertEqual(task['schedulerId'], 'gecko-level-4')
# make sure the dependencies exist, at least
for depid in task.get('dependencies', []):
if depid is 'decisiontask':
@ -65,7 +66,7 @@ class TestCreate(unittest.TestCase):
graph = Graph(nodes={'tid-a'}, edges=set())
taskgraph = TaskGraph(tasks, graph)
create.create_tasks(taskgraph, label_to_taskid)
create.create_tasks(taskgraph, label_to_taskid, {'level': '4'})
for tid, task in self.created_tasks.iteritems():
self.assertEqual(task.get('dependencies'), [os.environ['TASK_ID']])