Chromium Code Reviews| 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 'swarming_task_id:%s' % task_id, | 297 'swarming_task_id:%s' % task_id, |
| 298 ]) | 298 ]) |
| 299 task_req = res.get('request', {}) | 299 task_req = res.get('request', {}) |
| 300 for t in task_req.get('tags', []): | 300 for t in task_req.get('tags', []): |
| 301 build.tags.append('swarming_tag:%s' % t) | 301 build.tags.append('swarming_tag:%s' % t) |
| 302 for d in task_req.get('properties', {}).get('dimensions', []): | 302 for d in task_req.get('properties', {}).get('dimensions', []): |
| 303 build.tags.append('swarming_dimension:%s:%s' % (d['key'], d['value'])) | 303 build.tags.append('swarming_dimension:%s:%s' % (d['key'], d['value'])) |
| 304 | 304 |
| 305 # Mark the build as leased. | 305 # Mark the build as leased. |
| 306 assert 'expiration_secs' in task, task | 306 assert 'expiration_secs' in task, task |
| 307 # task['expiration_secs'] is max time for the task to be pending | |
| 307 task_expiration = datetime.timedelta(seconds=int(task['expiration_secs'])) | 308 task_expiration = datetime.timedelta(seconds=int(task['expiration_secs'])) |
| 309 # task['execution_timeout_secs'] is max time for the task to run | |
| 310 task_expiration += datetime.timedelta( | |
| 311 seconds=int(task['properties']['execution_timeout_secs'])) | |
| 308 extra_time = datetime.timedelta(hours=1) | 312 extra_time = datetime.timedelta(hours=1) |
|
Vadim Sh.
2016/06/22 00:09:44
it already included extra hour...
nodir
2016/06/22 00:15:45
removed it and added hour to task_expiration
| |
| 309 build.lease_expiration_date = utils.utcnow() + task_expiration + extra_time | 313 build.lease_expiration_date = utils.utcnow() + task_expiration + extra_time |
| 310 build.regenerate_lease_key() | 314 build.regenerate_lease_key() |
| 311 build.leasee = _self_identity() | 315 build.leasee = _self_identity() |
| 312 build.never_leased = False | 316 build.never_leased = False |
| 313 | 317 |
| 314 # Make it STARTED right away | 318 # Make it STARTED right away |
| 315 # because swarming does not notify on task start. | 319 # because swarming does not notify on task start. |
| 316 build.status = model.BuildStatus.STARTED | 320 build.status = model.BuildStatus.STARTED |
| 317 url_format = bucket_cfg.swarming.url_format or DEFAULT_URL_FORMAT | 321 url_format = bucket_cfg.swarming.url_format or DEFAULT_URL_FORMAT |
| 318 build.url = url_format.format( | 322 build.url = url_format.format( |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 def _extend_unique(target, items): | 630 def _extend_unique(target, items): |
| 627 for x in items: | 631 for x in items: |
| 628 if x not in target: # pragma: no branch | 632 if x not in target: # pragma: no branch |
| 629 target.append(x) | 633 target.append(x) |
| 630 | 634 |
| 631 | 635 |
| 632 class TaskToken(tokens.TokenKind): | 636 class TaskToken(tokens.TokenKind): |
| 633 expiration_sec = 60 * 60 * 24 # 24 hours. | 637 expiration_sec = 60 * 60 * 24 # 24 hours. |
| 634 secret_key = auth.SecretKey('swarming_task_token', scope='local') | 638 secret_key = auth.SecretKey('swarming_task_token', scope='local') |
| 635 version = 1 | 639 version = 1 |
| OLD | NEW |