Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: scripts/slave/remote_run.py

Issue 2158593002: remote_run: Allow recipe engine pinning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import copy 7 import copy
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
(...skipping 14 matching lines...) Expand all
25 from slave import infra_platform 25 from slave import infra_platform
26 from slave import logdog_bootstrap 26 from slave import logdog_bootstrap
27 from slave import monitoring_utils 27 from slave import monitoring_utils
28 from slave import robust_tempdir 28 from slave import robust_tempdir
29 from slave import update_scripts 29 from slave import update_scripts
30 30
31 31
32 LOGGER = logging.getLogger('remote_run') 32 LOGGER = logging.getLogger('remote_run')
33 33
34 34
35 # CIPD_PINS is a mapping of master name to pinned recipe engine CIPD package
36 # version. If no pin is found, the CIPD pin for "None" will be used.
37 _CIPD_PINS = {
38 # Default recipe engine pin.
39 None: 'latest',
40
41 # Custom per-master pins.
42 'chromium.infra': 'canary',
43 }
44
45
35 def _call(cmd, **kwargs): 46 def _call(cmd, **kwargs):
36 LOGGER.info('Executing command: %s', cmd) 47 LOGGER.info('Executing command: %s', cmd)
37 exit_code = subprocess.call(cmd, **kwargs) 48 exit_code = subprocess.call(cmd, **kwargs)
38 LOGGER.info('Command %s finished with exit code %d.', cmd, exit_code) 49 LOGGER.info('Command %s finished with exit code %d.', cmd, exit_code)
39 return exit_code 50 return exit_code
40 51
41 52
42 def _install_cipd_packages(path, *packages): 53 def _install_cipd_packages(path, *packages):
43 """Bootstraps CIPD in |path| and installs requested |packages|. 54 """Bootstraps CIPD in |path| and installs requested |packages|.
44 55
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 # confusing errors. 144 # confusing errors.
134 for p in (os.path.join(buildbot_workdir, x) 145 for p in (os.path.join(buildbot_workdir, x)
135 for x in os.listdir(buildbot_workdir)): 146 for x in os.listdir(buildbot_workdir)):
136 LOGGER.info('Deleting %r', p) 147 LOGGER.info('Deleting %r', p)
137 chromium_utils.RemovePath(p) 148 chromium_utils.RemovePath(p)
138 except Exception as e: 149 except Exception as e:
139 # It's preferred that we keep going rather than fail the build 150 # It's preferred that we keep going rather than fail the build
140 # on optional cleanup. 151 # on optional cleanup.
141 LOGGER.exception('Buildbot workdir cleanup failed: %s', e) 152 LOGGER.exception('Buildbot workdir cleanup failed: %s', e)
142 153
154 # Should we use a CIPD pin?
155 mastername = properties.get('mastername')
156 cipd_pin = None
157 if mastername:
158 cipd_pin = _CIPD_PINS.get(mastername)
159 if not cipd_pin:
160 cipd_pin = _CIPD_PINS[None]
161
143 cipd_path = os.path.join(basedir, '.remote_run_cipd') 162 cipd_path = os.path.join(basedir, '.remote_run_cipd')
144 _install_cipd_packages( 163 _install_cipd_packages(
145 cipd_path, cipd.CipdPackage('infra/recipes-py', 'latest')) 164 cipd_path, cipd.CipdPackage('infra/recipes-py', cipd_pin))
146 165
147 recipe_result_path = os.path.join(tempdir, 'recipe_result.json') 166 recipe_result_path = os.path.join(tempdir, 'recipe_result.json')
148 recipe_cmd = [ 167 recipe_cmd = [
149 sys.executable, 168 sys.executable,
150 os.path.join(cipd_path, 'recipes.py'), 169 os.path.join(cipd_path, 'recipes.py'),
151 '--verbose', 170 '--verbose',
152 'remote', 171 'remote',
153 '--repository', args.repository, 172 '--repository', args.repository,
154 '--revision', args.revision, 173 '--revision', args.revision,
155 '--workdir', os.path.join(tempdir, 'rw'), 174 '--workdir', os.path.join(tempdir, 'rw'),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 # Re-execute with the updated remote_run.py. 217 # Re-execute with the updated remote_run.py.
199 return _call([sys.executable] + argv) 218 return _call([sys.executable] + argv)
200 219
201 stream = annotator.StructuredAnnotationStream() 220 stream = annotator.StructuredAnnotationStream()
202 with stream.step('remote_run_result'): 221 with stream.step('remote_run_result'):
203 return main(argv) 222 return main(argv)
204 223
205 224
206 if __name__ == '__main__': 225 if __name__ == '__main__':
207 sys.exit(shell_main(sys.argv)) 226 sys.exit(shell_main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698