Chromium Code Reviews| Index: scripts/slave/annotated_run.py |
| diff --git a/scripts/slave/annotated_run.py b/scripts/slave/annotated_run.py |
| index 136e84bde1fd9c6e37f5af71d4a00c1f94b58d0c..ed5b66e313913142df7821b852b1f4940b33df9d 100755 |
| --- a/scripts/slave/annotated_run.py |
| +++ b/scripts/slave/annotated_run.py |
| @@ -3,6 +3,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import json |
| import optparse |
| import os |
| import subprocess |
| @@ -23,33 +24,41 @@ from recipe_engine import main as recipe_main |
| def get_recipe_properties(factory_properties, build_properties): |
| """Constructs the recipe's properties from buildbot's properties. |
| - This merges factory_properties and build_properties. Furthermore, it |
| - tries to reconstruct the 'recipe' property from builders.pyl if it isn't |
| - already there, and in that case merges in properties form builders.pyl. |
| + This retrieves the current factory properties from the master_config |
| + in the slave's checkout (the factory properties handed to us from the |
| + master might be out of date), and merges in the build properties. |
| + |
| + Using the values from the checkout allows us to do things like change |
| + the recipe and other factory properties for a builder without needing |
| + a master restart. |
| """ |
| - properties = factory_properties.copy() |
| + mastername = factory_properties['mastername'] |
| + buildername = factory_properties['buildername'] |
|
Paweł Hajdan Jr.
2015/06/11 08:38:19
How does this interact with e.g. running a recipe
|
| + |
| + # Get the recipe and otherfactory properties from the current |
| + # checked-out copies of the master.cfg on the slave, rather than taking what |
| + # was handed to us from the master. The latter might be out-of-date. |
| + script_path = os.path.join(BUILD_ROOT, 'scripts', 'slave', |
| + 'dump_factory_properties.py') |
| + dump_cmd = [sys.executable, |
| + script_path, |
| + mastername, |
| + buildername] |
| + proc = subprocess.Popen(dump_cmd, cwd=BUILD_ROOT, stdout=subprocess.PIPE) |
| + out, _ = proc.communicate() |
| + output_obj = json.loads(out) |
| + |
| + if output_obj['result']: |
| + raise LookupError('Failed to get the current factory properties for ' |
| + '%s on %s: %s' % (buildername, mastername, |
| + output_obj['message'])) |
| + |
| + if 'recipe' not in output_obj['factory_properties']: |
| + raise LookupError('Cannot find recipe for %s on %s' % |
| + (buildername, mastername)) |
| + |
| + properties = output_obj['factory_properties'].copy() |
| properties.update(build_properties) |
| - |
| - # Try to reconstruct the recipe from builders.pyl if not given. |
| - if 'recipe' not in properties: |
| - mastername = properties['mastername'] |
| - buildername = properties['buildername'] |
| - |
| - master_path = chromium_utils.MasterPath(mastername) |
| - builders_file = os.path.join(master_path, 'builders.pyl') |
| - if os.path.isfile(builders_file): |
| - builders = chromium_utils.ReadBuildersFile(builders_file) |
| - assert buildername in builders['builders'], ( |
| - 'buildername %s is not listed in %s' % (buildername, builders_file)) |
| - builder = builders['builders'][buildername] |
| - |
| - # Update properties with builders.pyl data. |
| - properties['recipe'] = builder['recipe'] |
| - properties.update(builder.get('properties', {})) |
| - else: |
| - raise LookupError('Cannot find recipe for %s on %s' % |
| - (build_properties['buildername'], |
| - build_properties['mastername'])) |
| return properties |