| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ]) | 109 ]) |
| 110 | 110 |
| 111 # Named caches options. | 111 # Named caches options. |
| 112 # Specify --named-cache-root unconditionally so run_isolated.py never creates | 112 # Specify --named-cache-root unconditionally so run_isolated.py never creates |
| 113 # "named_caches" dir and always operats in "c" dir. | 113 # "named_caches" dir and always operats in "c" dir. |
| 114 cmd.extend(['--named-cache-root', os.path.join(bot_dir, 'c')]) | 114 cmd.extend(['--named-cache-root', os.path.join(bot_dir, 'c')]) |
| 115 if task_details.caches: | 115 if task_details.caches: |
| 116 for c in task_details.caches: | 116 for c in task_details.caches: |
| 117 cmd.extend(['--named-cache', c['name'], c['path']]) | 117 cmd.extend(['--named-cache', c['name'], c['path']]) |
| 118 | 118 |
| 119 # Expected output files: |
| 120 for output in task_details.outputs: |
| 121 cmd.extend(['--output', output]) |
| 122 |
| 119 # CIPD options. | 123 # CIPD options. |
| 120 if task_details.cipd_input and task_details.cipd_input.get('packages'): | 124 if task_details.cipd_input and task_details.cipd_input.get('packages'): |
| 121 for pkg in task_details.cipd_input.get('packages'): | 125 for pkg in task_details.cipd_input.get('packages'): |
| 122 cmd.extend([ | 126 cmd.extend([ |
| 123 '--cipd-package', | 127 '--cipd-package', |
| 124 '%s:%s:%s' % (pkg['path'], pkg['package_name'], pkg['version'])]) | 128 '%s:%s:%s' % (pkg['path'], pkg['package_name'], pkg['version'])]) |
| 125 cmd.extend( | 129 cmd.extend( |
| 126 [ | 130 [ |
| 127 '--cipd-cache', os.path.join(bot_dir, 'cipd_cache'), | 131 '--cipd-cache', os.path.join(bot_dir, 'cipd_cache'), |
| 128 '--cipd-client-package', | 132 '--cipd-client-package', |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 186 |
| 183 self.caches = data.get('caches') | 187 self.caches = data.get('caches') |
| 184 | 188 |
| 185 self.env = { | 189 self.env = { |
| 186 k.encode('utf-8'): v.encode('utf-8') for k, v in data['env'].iteritems() | 190 k.encode('utf-8'): v.encode('utf-8') for k, v in data['env'].iteritems() |
| 187 } | 191 } |
| 188 self.grace_period = data['grace_period'] | 192 self.grace_period = data['grace_period'] |
| 189 self.hard_timeout = data['hard_timeout'] | 193 self.hard_timeout = data['hard_timeout'] |
| 190 self.io_timeout = data['io_timeout'] | 194 self.io_timeout = data['io_timeout'] |
| 191 self.task_id = data['task_id'] | 195 self.task_id = data['task_id'] |
| 196 self.outputs = data.get('outputs', []) |
| 192 | 197 |
| 193 @staticmethod | 198 @staticmethod |
| 194 def load(path): | 199 def load(path): |
| 195 """Loads the TaskDetails from a file on disk (specified via --in-file). | 200 """Loads the TaskDetails from a file on disk (specified via --in-file). |
| 196 | 201 |
| 197 Raises InternalError if the file can't be read or parsed. | 202 Raises InternalError if the file can't be read or parsed. |
| 198 """ | 203 """ |
| 199 try: | 204 try: |
| 200 with open(path, 'rb') as f: | 205 with open(path, 'rb') as f: |
| 201 return TaskDetails(json.load(f)) | 206 return TaskDetails(json.load(f)) |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 options.start = now | 663 options.start = now |
| 659 | 664 |
| 660 try: | 665 try: |
| 661 load_and_run( | 666 load_and_run( |
| 662 options.in_file, options.swarming_server, options.cost_usd_hour, | 667 options.in_file, options.swarming_server, options.cost_usd_hour, |
| 663 options.start, options.out_file, options.min_free_space, | 668 options.start, options.out_file, options.min_free_space, |
| 664 options.bot_file, options.auth_params_file) | 669 options.bot_file, options.auth_params_file) |
| 665 return 0 | 670 return 0 |
| 666 finally: | 671 finally: |
| 667 logging.info('quitting') | 672 logging.info('quitting') |
| OLD | NEW |