Bug 1465117 - Take two at updating backfill task. Use modifier this time. r=dustin,jmaher

MozReview-Commit-ID: CAs0WRb839r

--HG--
extra : rebase_source : 5da88d38315f8b6795aa6d5a97de63883eda1ab0
This commit is contained in:
Brian Stack 2018-06-08 12:08:34 -07:00
parent cd8c9f6a3e
commit 3ba851c889
4 changed files with 45 additions and 16 deletions

View File

@ -272,7 +272,6 @@ class MachCommands(MachCommandBase):
help='Action callback name (Python function name)')
def test_action_callback(self, **options):
import taskgraph.parameters
from taskgraph.util.taskcluster import get_task_definition
import taskgraph.actions
import yaml
@ -288,12 +287,6 @@ class MachCommands(MachCommandBase):
try:
self.setup_logging()
task_id = options['task_id']
if options['task']:
task = load_data(options['task'])
elif task_id:
task = get_task_definition(task_id)
else:
task = None
if options['input']:
input = load_data(options['input'])
@ -308,7 +301,6 @@ class MachCommands(MachCommandBase):
return taskgraph.actions.trigger_action_callback(
task_group_id=options['task_group_id'],
task_id=task_id,
task=task,
input=input,
callback=options['callback'],
parameters=parameters,

View File

@ -44,6 +44,23 @@ logger = logging.getLogger(__name__)
'title': 'Depth',
'description': ('The number of previous pushes before the current '
'push to attempt to trigger this task on.')
},
'inclusive': {
'type': 'boolean',
'default': False,
'title': 'Inclusive Range',
'description': ('If true, the backfill will also retrigger the task '
'on the selected push.')
},
'addGeckoProfile': {
'type': 'boolean',
'default': False,
'title': 'Add Gecko Profile',
'description': 'If true, appends --geckoProfile to mozharness options.'
},
'testPath': {
'type': 'string',
'title': 'Test Path',
}
},
'additionalProperties': False
@ -53,8 +70,9 @@ logger = logging.getLogger(__name__)
def backfill_action(parameters, graph_config, input, task_group_id, task_id, task):
label = task['metadata']['name']
pushes = []
depth = input.get('depth', 5)
end_id = int(parameters['pushlog_id']) - 1
inclusive_tweak = 1 if input.get('inclusive') else 0
depth = input.get('depth', 5) + inclusive_tweak
end_id = int(parameters['pushlog_id']) - (1 - inclusive_tweak)
while True:
start_id = max(end_id - depth, 0)
@ -90,8 +108,22 @@ def backfill_action(parameters, graph_config, input, task_group_id, task_id, tas
continue
if label in full_task_graph.tasks.keys():
create_tasks(
[label], full_task_graph, label_to_taskid,
push_params, push_decision_task_id, push)
def modifier(task):
if task.label != label:
return task
if input.get('addGeckoProfile'):
mh = task.task['payload'].setdefault('env', {}) \
.get('MOZHARNESS_OPTIONS', '')
task.task['payload']['env']['MOZHARNESS_OPTIONS'] = mh + ' --geckoProfile'
task.task['extra']['treeherder']['symbol'] += '-p'
if input.get('testPath'):
env = task.task['payload'].setdefault('env', {})
env['MOZHARNESS_TEST_PATHS'] = input.get('testPath')
task.task['extra']['treeherder']['symbol'] += '-b'
return task
create_tasks([label], full_task_graph, label_to_taskid,
push_params, push_decision_task_id, push, modifier=modifier)
else:
logging.info('Could not find {} on {}. Skipping.'.format(label, push))

View File

@ -111,13 +111,18 @@ def update_parent(task, graph):
def create_tasks(to_run, full_task_graph, label_to_taskid,
params, decision_task_id=None, suffix=''):
params, decision_task_id=None, suffix='', modifier=lambda t: t):
"""Create new tasks. The task definition will have {relative-datestamp':
'..'} rendered just like in a decision task. Action callbacks should use
this function to create new tasks,
allowing easy debugging with `mach taskgraph action-callback --test`.
This builds up all required tasks to run in order to run the tasks requested.
Optionally this function takes a `modifier` function that is passed in each
task before it is put into a new graph. It should return a valid task. Note
that this is passed _all_ tasks in the graph, not just the set in to_run. You
may want to skip modifying tasks not in your to_run list.
If you wish to create the tasks in a new group, leave out decision_task_id."""
if suffix != '':
suffix = '-{}'.format(suffix)
@ -129,7 +134,7 @@ def create_tasks(to_run, full_task_graph, label_to_taskid,
target_graph = full_task_graph.graph.transitive_closure(to_run)
target_task_graph = TaskGraph(
{l: full_task_graph[l] for l in target_graph.nodes},
{l: modifier(full_task_graph[l]) for l in target_graph.nodes},
target_graph)
target_task_graph.for_each_task(update_parent)
optimized_task_graph, label_to_taskid = optimize_task_graph(target_task_graph,

View File

@ -21,7 +21,7 @@ class Task(object):
- task_id -- TaskCluster taskId under which this task will be created
This class is just a convenience wraper for the data type and managing
This class is just a convenience wrapper for the data type and managing
display, comparison, serialization, etc. It has no functionality of its own.
"""
def __init__(self, kind, label, attributes, task,