Bug 1514087: [taskgraph] Add an option to not optimize target tasks in cron graphs; r=dustin
authorTom Prince <mozilla@hocat.ca>
Wed, 26 Dec 2018 14:43:34 +0000
changeset 509094 6c08d8d74b4085a9a3bbb639c8f66eb7d0b20c73
parent 509093 b58eeeefbc959db34c0a9e5e966cd4e15e044bb9
child 509095 91582d65479cd72817a20fe769168b13edce3bc2
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1514087
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514087: [taskgraph] Add an option to not optimize target tasks in cron graphs; r=dustin This allows the target tasks to include cached tasks, which by default, get optimized out of the graph on on-`try` branches. Differential Revision: https://phabricator.services.mozilla.com/D15278
.cron.yml
taskcluster/mach_commands.py
taskcluster/taskgraph/cron/decision.py
taskcluster/taskgraph/cron/schema.py
taskcluster/taskgraph/decision.py
--- a/.cron.yml
+++ b/.cron.yml
@@ -99,16 +99,17 @@ jobs:
               mozilla-central: [{hour: 10, minute: 0}]
               # No default
 
     - name: customv8-update
       job:
           type: decision-task
           treeherder-symbol: customv8
           target-tasks-method: customv8_update
+          optimize-target-tasks: false
       run-on-projects:
           - mozilla-central
       when:
           by-project:
               mozilla-central: [{hour: 10, minute: 30}]
 
     - name: bouncer-check
       job:
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -8,16 +8,17 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import json
 import logging
 import os
 import sys
 import traceback
 import re
+from distutils.util import strtobool
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
     SubCommand,
 )
 
@@ -166,16 +167,22 @@ class MachCommands(MachCommandBase):
     @CommandArgument('--owner',
                      required=True,
                      help='email address of who owns this graph')
     @CommandArgument('--level',
                      required=True,
                      help='SCM level of this repository')
     @CommandArgument('--target-tasks-method',
                      help='method for selecting the target tasks to generate')
+    @CommandArgument('--optimize-target-tasks',
+                     type=strtobool,
+                     nargs='?', const='true',
+                     help='If specified, this indicates whether the target '
+                          'tasks are eligible for optimization. Otherwise, '
+                          'the default for the project is used.')
     @CommandArgument('--try-task-config-file',
                      help='path to try task configuration file')
     def taskgraph_decision(self, **options):
         """Run the decision task: generate a task graph and submit to
         TaskCluster.  This is only meant to be called within decision tasks,
         and requires a great many arguments.  Commands like `mach taskgraph
         optimized` are better suited to use on the command line, and can take
         the parameters file generated by a decision task.  """
--- a/taskcluster/taskgraph/cron/decision.py
+++ b/taskcluster/taskgraph/cron/decision.py
@@ -16,16 +16,20 @@ import slugid
 from taskgraph.util.time import current_json_time
 from taskgraph.util.hg import find_hg_revision_push_info
 
 
 def run_decision_task(job, params, root):
     arguments = []
     if 'target-tasks-method' in job:
         arguments.append('--target-tasks-method={}'.format(job['target-tasks-method']))
+    if job.get('optimize-target-tasks') is not None:
+        arguments.append('--optimize-target-tasks={}'.format(
+            str(job['optimize-target-tasks']).lower(),
+        ))
     return [
         make_decision_task(
             params,
             symbol=job['treeherder-symbol'],
             arguments=arguments,
             root=root),
     ]
 
--- a/taskcluster/taskgraph/cron/schema.py
+++ b/taskcluster/taskgraph/cron/schema.py
@@ -2,17 +2,17 @@
 
 # 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 __future__ import absolute_import, print_function, unicode_literals
 
-from voluptuous import Any, Required, All
+from voluptuous import Any, Required, All, Optional
 from taskgraph.util.schema import (
     optionally_keyed_by,
     validate_schema,
     Schema,
 )
 
 
 def even_15_minutes(minutes):
@@ -31,16 +31,23 @@ cron_yml_schema = Schema({
         Required('job'): {
             Required('type'): 'decision-task',
 
             # Treeherder symbol for the cron task
             Required('treeherder-symbol'): basestring,
 
             # --target-tasks-method './mach taskgraph decision' argument
             'target-tasks-method': basestring,
+
+            Optional(
+                'optimize-target-tasks',
+                description='If specified, this indicates whether the target '
+                            'tasks are eligible for optimization. Otherwise, '
+                            'the default for the project is used.',
+            ): bool,
         },
 
         # when to run it
 
         # Optional set of projects on which this job should run; if omitted, this will
         # run on all projects for which cron tasks are set up.  This works just like the
         # `run_on_projects` attribute, where strings like "release" and "integration" are
         # expanded to cover multiple repositories.  (taskcluster/docs/attributes.rst)
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -281,16 +281,19 @@ def get_decision_parameters(config, opti
     else:
         # if try_task_config.json is present, load it
         task_config_file = os.path.join(os.getcwd(), 'try_task_config.json')
 
     # load try settings
     if 'try' in project:
         set_try_config(parameters, task_config_file)
 
+    if options.get('optimize_target_tasks') is not None:
+        parameters['optimize_target_tasks'] = options['optimize_target_tasks']
+
     result = Parameters(**parameters)
     result.check()
     return result
 
 
 def set_try_config(parameters, task_config_file):
     if os.path.isfile(task_config_file):
         logger.info("using try tasks from {}".format(task_config_file))