Bug 1351010 - Fix return statements in optimize.py; r=dustin
☠☠ backed out by 165d2a346e10 ☠ ☠
authorAyodeji Oyewole <ayodeji.oyewole@gmail.com>
Sat, 01 Apr 2017 15:59:36 -0400
changeset 355017 e5073b47f5c8f7aa8fc2e5578d4fcc6a6c79deed
parent 355016 026696e3640b20ce0cdda3229ec282e52539d2ed
child 355018 47b53e3d4b27c0b900c06180d857dac1de1d3241
push id41525
push userdmitchell@mozilla.com
push dateWed, 26 Apr 2017 13:12:39 +0000
treeherderautoland@e5073b47f5c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1351010
milestone55.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 1351010 - Fix return statements in optimize.py; r=dustin MozReview-Commit-ID: ctgm1fw0Fo *** Bug 1351010 - Completely fixed; r?dustin MozReview-Commit-ID: HKoWcINVSnV
taskcluster/taskgraph/optimize.py
--- a/taskcluster/taskgraph/optimize.py
+++ b/taskcluster/taskgraph/optimize.py
@@ -71,21 +71,21 @@ def resolve_task_references(label, task_
 def optimize_task(task, params):
     """
     Optimize a single task by running its optimizations in order until one
     succeeds.
     """
     for opt in task.optimizations:
         opt_type, args = opt[0], opt[1:]
         opt_fn = _optimizations[opt_type]
-        optimized, task_id = opt_fn(task, params, *args)
-        if optimized or task_id:
-            return optimized, task_id
+        opt_result = opt_fn(task, params, *args)
+        if opt_result:
+            return opt_result
 
-    return False, None
+    return False
 
 
 def annotate_task_graph(target_task_graph, params, do_not_optimize,
                         named_links_dict, label_to_taskid, existing_tasks):
     """
     Annotate each task in the graph with .optimized (boolean) and .task_id
     (possibly None), following the rules for optimization and calling the task
     kinds' `optimize_task` method.
@@ -113,17 +113,25 @@ def annotate_task_graph(target_task_grap
         if label in do_not_optimize:
             optimized = False
         # Let's check whether this task has been created before
         elif existing_tasks is not None and label in existing_tasks:
             optimized = True
             replacement_task_id = existing_tasks[label]
         # otherwise, examine the task itself (which may be an expensive operation)
         else:
-            optimized, replacement_task_id = optimize_task(task, params)
+            opt_result = optimize_task(task, params)
+
+            # use opt_result to determine values for optimized, replacement_task_id
+            optimized = True
+            replacement_task_id = None
+            if opt_result is False:
+                optimized = False
+            elif opt_result is not True:
+                replacement_task_id = opt_result
 
         task.optimized = optimized
         task.task_id = replacement_task_id
         if replacement_task_id:
             label_to_taskid[label] = replacement_task_id
 
         if optimized:
             if replacement_task_id:
@@ -190,21 +198,21 @@ def optimization(name):
 
 @optimization('index-search')
 def opt_index_search(task, params, index_path):
     try:
         task_id = find_task_id(
             index_path,
             use_proxy=bool(os.environ.get('TASK_ID')))
 
-        return True, task_id
+        return task_id or True
     except requests.exceptions.HTTPError:
         pass
 
-    return False, None
+    return False
 
 
 @optimization('seta')
 def opt_seta(task, params):
     bbb_task = False
 
     # for bbb tasks we need to send in the buildbot buildername
     if task.task.get('provisionerId', '') == 'buildbot-bridge':
@@ -216,25 +224,25 @@ def opt_seta(task, params):
     # we would like to return 'False, None' while it's high_value_task
     # and we wouldn't optimize it. Otherwise, it will return 'True, None'
     if is_low_value_task(label,
                          params.get('project'),
                          params.get('pushlog_id'),
                          params.get('pushdate'),
                          bbb_task):
         # Always optimize away low-value tasks
-        return True, None
+        return True
     else:
-        return False, None
+        return False
 
 
 @optimization('files-changed')
 def opt_files_changed(task, params, file_patterns):
     # pushlog_id == -1 - this is the case when run from a cron.yml job
     if params.get('pushlog_id') == -1:
-        return True, None
+        return True
 
     changed = files_changed.check(params, file_patterns)
     if not changed:
         logger.debug('no files found matching a pattern in `when.files-changed` for ' +
                      task.label)
-        return True, None
-    return False, None
+        return True
+    return False