| OLD | NEW |
| 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 """This module integrates buildbucket with swarming. | 5 """This module integrates buildbucket with swarming. |
| 6 | 6 |
| 7 A bucket config may have "swarming" field that specifies how a builder | 7 A bucket config may have "swarming" field that specifies how a builder |
| 8 is mapped to a recipe. If build is scheduled for a bucket/builder | 8 is mapped to a recipe. If build is scheduled for a bucket/builder |
| 9 with swarming configuration, the integration overrides the default behavior. | 9 with swarming configuration, the integration overrides the default behavior. |
| 10 | 10 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 _extend_unique(swarming_tags, builder_cfg.swarming_tags) | 217 _extend_unique(swarming_tags, builder_cfg.swarming_tags) |
| 218 _extend_unique(swarming_tags, build.tags) | 218 _extend_unique(swarming_tags, build.tags) |
| 219 swarming_tags.sort() | 219 swarming_tags.sort() |
| 220 | 220 |
| 221 task_properties = task.setdefault('properties', {}) | 221 task_properties = task.setdefault('properties', {}) |
| 222 task_properties['dimensions'] = _prepare_dimensions( | 222 task_properties['dimensions'] = _prepare_dimensions( |
| 223 task_properties.get('dimensions', []), | 223 task_properties.get('dimensions', []), |
| 224 swarming_cfg.common_dimensions, | 224 swarming_cfg.common_dimensions, |
| 225 builder_cfg.dimensions | 225 builder_cfg.dimensions |
| 226 ) | 226 ) |
| 227 if builder_cfg.execution_timeout_secs > 0: |
| 228 task_properties['execution_timeout_secs'] = ( |
| 229 builder_cfg.execution_timeout_secs) |
| 227 | 230 |
| 228 task['pubsub_topic'] = ( | 231 task['pubsub_topic'] = ( |
| 229 'projects/%s/topics/%s' % | 232 'projects/%s/topics/%s' % |
| 230 (app_identity.get_application_id(), PUBSUB_TOPIC)) | 233 (app_identity.get_application_id(), PUBSUB_TOPIC)) |
| 231 task['pubsub_auth_token'] = TaskToken.generate() | 234 task['pubsub_auth_token'] = TaskToken.generate() |
| 232 task['pubsub_userdata'] = json.dumps({ | 235 task['pubsub_userdata'] = json.dumps({ |
| 233 'created_ts': utils.datetime_to_timestamp(utils.utcnow()), | 236 'created_ts': utils.datetime_to_timestamp(utils.utcnow()), |
| 234 'swarming_hostname': swarming_cfg.hostname, | 237 'swarming_hostname': swarming_cfg.hostname, |
| 235 }, sort_keys=True) | 238 }, sort_keys=True) |
| 236 raise ndb.Return(task) | 239 raise ndb.Return(task) |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 def _extend_unique(target, items): | 629 def _extend_unique(target, items): |
| 627 for x in items: | 630 for x in items: |
| 628 if x not in target: # pragma: no branch | 631 if x not in target: # pragma: no branch |
| 629 target.append(x) | 632 target.append(x) |
| 630 | 633 |
| 631 | 634 |
| 632 class TaskToken(tokens.TokenKind): | 635 class TaskToken(tokens.TokenKind): |
| 633 expiration_sec = 60 * 60 * 24 # 24 hours. | 636 expiration_sec = 60 * 60 * 24 # 24 hours. |
| 634 secret_key = auth.SecretKey('swarming_task_token', scope='local') | 637 secret_key = auth.SecretKey('swarming_task_token', scope='local') |
| 635 version = 1 | 638 version = 1 |
| OLD | NEW |