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

Side by Side Diff: recipe_modules/bot_update/api.py

Issue 2175103002: Fix bot_update to correctly handle exceptions (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix logic to correctly raise exception 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
« 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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 """Recipe module to ensure a checkout is consistant on a bot.""" 6 """Recipe module to ensure a checkout is consistant on a bot."""
7 7
8 from recipe_engine import recipe_api 8 from recipe_engine import recipe_api
9 9
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 output_manifest=output_manifest, fixed_revisions=fixed_revisions) 224 output_manifest=output_manifest, fixed_revisions=fixed_revisions)
225 225
226 # Add suffixes to the step name, if specified. 226 # Add suffixes to the step name, if specified.
227 name = 'bot_update' 227 name = 'bot_update'
228 if not patch: 228 if not patch:
229 name += ' (without patch)' 229 name += ' (without patch)'
230 if suffix: 230 if suffix:
231 name += ' - %s' % suffix 231 name += ' - %s' % suffix
232 232
233 # Ah hah! Now that everything is in place, lets run bot_update! 233 # Ah hah! Now that everything is in place, lets run bot_update!
234 step_result = None
234 try: 235 try:
235 # 87 and 88 are the 'patch failure' codes for patch download and patch 236 # 87 and 88 are the 'patch failure' codes for patch download and patch
236 # apply, respectively. We don't actually use the error codes, and instead 237 # apply, respectively. We don't actually use the error codes, and instead
237 # rely on emitted json to determine cause of failure. 238 # rely on emitted json to determine cause of failure.
238 self(name, cmd, step_test_data=step_test_data, 239 step_result = self(name, cmd, step_test_data=step_test_data,
239 ok_ret=(0, 87, 88), **kwargs) 240 ok_ret=(0, 87, 88), **kwargs)
241 except self.m.step.StepFailure as f:
242 step_result = f.result
243 raise
240 finally: 244 finally:
241 step_result = self.m.step.active_result 245 if step_result:
242 self._last_returned_properties = step_result.json.output.get( 246 self._last_returned_properties = step_result.json.output.get(
243 'properties', {}) 247 'properties', {})
244 248
245 if update_presentation: 249 if update_presentation:
246 # Set properties such as got_revision. 250 # Set properties such as got_revision.
247 for prop_name, prop_value in self.last_returned_properties.iteritems(): 251 for prop_name, prop_value in (
248 step_result.presentation.properties[prop_name] = prop_value 252 self.last_returned_properties.iteritems()):
249 # Add helpful step description in the step UI. 253 step_result.presentation.properties[prop_name] = prop_value
250 if 'step_text' in step_result.json.output: 254 # Add helpful step description in the step UI.
251 step_text = step_result.json.output['step_text'] 255 if 'step_text' in step_result.json.output:
252 step_result.presentation.step_text = step_text 256 step_text = step_result.json.output['step_text']
253 # Add log line output. 257 step_result.presentation.step_text = step_text
254 if 'log_lines' in step_result.json.output: 258 # Add log line output.
255 for log_name, log_lines in step_result.json.output['log_lines']: 259 if 'log_lines' in step_result.json.output:
256 step_result.presentation.logs[log_name] = log_lines.splitlines() 260 for log_name, log_lines in step_result.json.output['log_lines']:
261 step_result.presentation.logs[log_name] = log_lines.splitlines()
257 262
258 # Set the "checkout" path for the main solution. 263 # Set the "checkout" path for the main solution.
259 # This is used by the Chromium module to figure out where to look for 264 # This is used by the Chromium module to figure out where to look for
260 # the checkout. 265 # the checkout.
261 # If there is a patch failure, emit another step that said things failed. 266 # If there is a patch failure, emit another step that said things
262 if step_result.json.output.get('patch_failure'): 267 # failed.
263 return_code = step_result.json.output.get('patch_apply_return_code') 268 if step_result.json.output.get('patch_failure'):
264 if return_code == 3: 269 return_code = step_result.json.output.get('patch_apply_return_code')
265 # This is download failure, hence an infra failure. 270 if return_code == 3:
266 # Sadly, python.failing_step doesn't support kwargs. 271 # This is download failure, hence an infra failure.
267 self.m.python.inline( 272 # Sadly, python.failing_step doesn't support kwargs.
268 'Patch failure', 273 self.m.python.inline(
269 ('import sys;' 274 'Patch failure',
270 'print "Patch download failed. See bot_update step for details";' 275 ('import sys;'
271 'sys.exit(1)'), 276 'print "Patch download failed. See bot_update step for'
272 infra_step=True, 277 ' details";sys.exit(1)'),
273 step_test_data=lambda: self.m.raw_io.test_api.output( 278 infra_step=True,
274 'Patch download failed. See bot_update step for details', 279 step_test_data=lambda: self.m.raw_io.test_api.output(
275 retcode=1) 280 'Patch download failed. See bot_update step for details',
276 ) 281 retcode=1)
277 else: 282 )
278 # This is actual patch failure. 283 else:
279 self.m.tryserver.set_patch_failure_tryjob_result() 284 # This is actual patch failure.
280 self.m.python.failing_step( 285 self.m.tryserver.set_patch_failure_tryjob_result()
281 'Patch failure', 'Check the bot_update step for details') 286 self.m.python.failing_step(
287 'Patch failure', 'Check the bot_update step for details')
282 288
283 # bot_update actually just sets root to be the folder name of the 289 # bot_update actually just sets root to be the folder name of the
284 # first solution. 290 # first solution.
285 if step_result.json.output['did_run']: 291 if step_result.json.output['did_run']:
286 co_root = step_result.json.output['root'] 292 co_root = step_result.json.output['root']
287 cwd = kwargs.get('cwd', self.m.path['slave_build']) 293 cwd = kwargs.get('cwd', self.m.path['slave_build'])
288 if 'checkout' not in self.m.path: 294 if 'checkout' not in self.m.path:
289 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 295 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
290 296
291 return step_result 297 return step_result
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