| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 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 """Runs a Swarming task. | 5 """Runs a Swarming task. |
| 6 | 6 |
| 7 Downloads all the necessary files to run the task, executes the command and | 7 Downloads all the necessary files to run the task, executes the command and |
| 8 streams results back to the Swarming server. | 8 streams results back to the Swarming server. |
| 9 | 9 |
| 10 The process exit code is 0 when the task was executed, even if the task itself | 10 The process exit code is 0 when the task was executed, even if the task itself |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 params['bot_overhead'] -= run_isolated_result.get( | 572 params['bot_overhead'] -= run_isolated_result.get( |
| 573 'cipd', {}).get('duration', 0) | 573 'cipd', {}).get('duration', 0) |
| 574 if params['bot_overhead'] < 0: | 574 if params['bot_overhead'] < 0: |
| 575 params['bot_overhead'] = 0 | 575 params['bot_overhead'] = 0 |
| 576 isolated_stats = run_isolated_result.get('stats', {}).get('isolated') | 576 isolated_stats = run_isolated_result.get('stats', {}).get('isolated') |
| 577 if isolated_stats: | 577 if isolated_stats: |
| 578 params['isolated_stats'] = isolated_stats | 578 params['isolated_stats'] = isolated_stats |
| 579 cipd_stats = run_isolated_result.get('stats', {}).get('cipd') | 579 cipd_stats = run_isolated_result.get('stats', {}).get('cipd') |
| 580 if cipd_stats: | 580 if cipd_stats: |
| 581 params['cipd_stats'] = cipd_stats | 581 params['cipd_stats'] = cipd_stats |
| 582 cipd_pins = run_isolated_result.get('cipd_pins') |
| 583 if cipd_pins: |
| 584 params['cipd_pins'] = cipd_pins |
| 582 except (IOError, OSError, ValueError) as e: | 585 except (IOError, OSError, ValueError) as e: |
| 583 logging.error('Swallowing error: %s', e) | 586 logging.error('Swallowing error: %s', e) |
| 584 if not must_signal_internal_failure: | 587 if not must_signal_internal_failure: |
| 585 must_signal_internal_failure = '%s\n%s' % ( | 588 must_signal_internal_failure = '%s\n%s' % ( |
| 586 e, traceback.format_exc()[-2048:]) | 589 e, traceback.format_exc()[-2048:]) |
| 587 # TODO(maruel): Send the internal failure here instead of sending it through | 590 # TODO(maruel): Send the internal failure here instead of sending it through |
| 588 # bot_main, this causes a race condition. | 591 # bot_main, this causes a race condition. |
| 589 if exit_code is None: | 592 if exit_code is None: |
| 590 exit_code = -1 | 593 exit_code = -1 |
| 591 params['hard_timeout'] = had_hard_timeout | 594 params['hard_timeout'] = had_hard_timeout |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 options.start = now | 637 options.start = now |
| 635 | 638 |
| 636 try: | 639 try: |
| 637 load_and_run( | 640 load_and_run( |
| 638 options.in_file, options.swarming_server, options.cost_usd_hour, | 641 options.in_file, options.swarming_server, options.cost_usd_hour, |
| 639 options.start, options.out_file, options.min_free_space, | 642 options.start, options.out_file, options.min_free_space, |
| 640 options.bot_file) | 643 options.bot_file) |
| 641 return 0 | 644 return 0 |
| 642 finally: | 645 finally: |
| 643 logging.info('quitting') | 646 logging.info('quitting') |
| OLD | NEW |