| OLD | NEW |
| 1 # Copyright 2017 The LUCI Authors. All rights reserved. | 1 # Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Entry point for fully-annotated builds. | 5 """Entry point for fully-annotated builds. |
| 6 | 6 |
| 7 This script is part of the effort to move all builds to annotator-based | 7 This script is part of the effort to move all builds to annotator-based |
| 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() | 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() |
| 9 found in scripts/master/factory/annotator_factory.py executes a single | 9 found in scripts/master/factory/annotator_factory.py executes a single |
| 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls | 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 Args: | 243 Args: |
| 244 name (str): The name of the client instance to retrieve. | 244 name (str): The name of the client instance to retrieve. |
| 245 """ | 245 """ |
| 246 return self._clients.get(name) | 246 return self._clients.get(name) |
| 247 | 247 |
| 248 def run_step(self, step_config): | 248 def run_step(self, step_config): |
| 249 """ | 249 """ |
| 250 Runs a step. | 250 Runs a step. |
| 251 | 251 |
| 252 Args: | 252 Args: |
| 253 step_config (recipe_api.StepConfig): The step configuration to run. | 253 step_config (recipe_api.StepClient.StepConfig): The step configuration to |
| 254 run. |
| 254 | 255 |
| 255 Returns: | 256 Returns: |
| 256 A StepData object containing the result of running the step. | 257 A StepData object containing the result of running the step. |
| 257 """ | 258 """ |
| 258 with util.raises((recipe_api.StepFailure, OSError), | 259 with util.raises((recipe_api.StepFailure, OSError), |
| 259 self._step_runner.stream_engine): | 260 self._step_runner.stream_engine): |
| 260 step_result = None | 261 step_result = None |
| 261 | 262 |
| 262 self._close_through_level(step_config.nest_level) | 263 self._close_through_level(step_config.nest_level) |
| 263 | 264 |
| 264 open_step = self._step_runner.open_step(step_config) | 265 open_step = self._step_runner.open_step(step_config) |
| 265 self._step_stack.append(self.ActiveStep( | 266 self._step_stack.append(self.ActiveStep( |
| 266 config=step_config, | 267 config=step_config, |
| 267 step_result=None, | 268 step_result=None, |
| 268 open_step=open_step)) | 269 open_step=open_step)) |
| 269 | 270 |
| 270 step_result = open_step.run() | 271 step_result = open_step.run() |
| 271 self._step_stack[-1] = ( | 272 self._step_stack[-1] = ( |
| 272 self._step_stack[-1]._replace(step_result=step_result)) | 273 self._step_stack[-1]._replace(step_result=step_result)) |
| 273 | 274 |
| 274 if step_result.retcode in step_config.ok_ret: | 275 if step_result.retcode in step_config.ok_ret: |
| 275 step_result.presentation.status = 'SUCCESS' | 276 step_result.presentation.status = 'SUCCESS' |
| 276 return step_result | 277 return step_result |
| 278 |
| 279 if not step_config.infra_step: |
| 280 state = 'FAILURE' |
| 281 exc = recipe_api.StepFailure |
| 277 else: | 282 else: |
| 278 if not step_config.infra_step: | 283 state = 'EXCEPTION' |
| 279 state = 'FAILURE' | 284 exc = recipe_api.InfraFailure |
| 280 exc = recipe_api.StepFailure | |
| 281 else: | |
| 282 state = 'EXCEPTION' | |
| 283 exc = recipe_api.InfraFailure | |
| 284 | 285 |
| 285 step_result.presentation.status = state | 286 step_result.presentation.status = state |
| 286 | 287 |
| 287 self._step_stack[-1].open_step.stream.write_line( | 288 self._step_stack[-1].open_step.stream.write_line( |
| 288 'step returned non-zero exit code: %d' % step_result.retcode) | 289 'step returned non-zero exit code: %d' % step_result.retcode) |
| 289 | 290 |
| 290 raise exc(step_config.name, step_result) | 291 raise exc(step_config.name, step_result) |
| 291 | 292 |
| 292 def run(self, recipe_script, api, properties): | 293 def run(self, recipe_script, api, properties): |
| 293 """Run a recipe represented by a recipe_script object. | 294 """Run a recipe represented by a recipe_script object. |
| 294 | 295 |
| 295 This function blocks until recipe finishes. | 296 This function blocks until recipe finishes. |
| 296 It mainly executes the recipe, and has some exception handling logic. | 297 It mainly executes the recipe, and has some exception handling logic. |
| 297 | 298 |
| 298 Args: | 299 Args: |
| 299 recipe_script: The recipe to run, as represented by a RecipeScript object. | 300 recipe_script: The recipe to run, as represented by a RecipeScript object. |
| 300 api: The api, with loaded module dependencies. | 301 api: The api, with loaded module dependencies. |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 ret = run_steps( | 726 ret = run_steps( |
| 726 properties, stream_engine, | 727 properties, stream_engine, |
| 727 step_runner.SubprocessStepRunner(stream_engine, engine_flags), | 728 step_runner.SubprocessStepRunner(stream_engine, engine_flags), |
| 728 universe_view, engine_flags=engine_flags, | 729 universe_view, engine_flags=engine_flags, |
| 729 emit_initial_properties=emit_initial_properties) | 730 emit_initial_properties=emit_initial_properties) |
| 730 finally: | 731 finally: |
| 731 os.chdir(old_cwd) | 732 os.chdir(old_cwd) |
| 732 | 733 |
| 733 return handle_recipe_return( | 734 return handle_recipe_return( |
| 734 ret, args.output_result_json, stream_engine, engine_flags) | 735 ret, args.output_result_json, stream_engine, engine_flags) |
| OLD | NEW |