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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 ) | 417 ) |
418 if state in ('PENDING', 'RUNNING'): | 418 if state in ('PENDING', 'RUNNING'): |
419 build.status = model.BuildStatus.STARTED | 419 build.status = model.BuildStatus.STARTED |
420 elif state in terminal_states: | 420 elif state in terminal_states: |
421 build.status = model.BuildStatus.COMPLETED | 421 build.status = model.BuildStatus.COMPLETED |
422 if state == 'CANCELED': | 422 if state == 'CANCELED': |
423 build.result = model.BuildResult.CANCELED | 423 build.result = model.BuildResult.CANCELED |
424 build.cancelation_reason = model.CancelationReason.CANCELED_EXPLICITLY | 424 build.cancelation_reason = model.CancelationReason.CANCELED_EXPLICITLY |
425 elif state == 'EXPIRED': | 425 elif state == 'EXPIRED': |
426 # Task did not start. | 426 # Task did not start. |
427 build.result = model.BuildResult.CANCELED | 427 build.result = model.BuildResult.FAILURE |
428 build.cancelation_reason = model.CancelationReason.TIMEOUT | 428 build.failure_reason = model.FailureReason.INFRA_FAILURE |
429 elif state == 'TIMED_OUT': | 429 elif state == 'TIMED_OUT': |
430 # Task started, but timed out. | 430 # Task started, but timed out. |
431 build.result = model.BuildResult.FAILURE | 431 build.result = model.BuildResult.FAILURE |
432 build.failure_reason = model.FailureReason.INFRA_FAILURE | 432 build.failure_reason = model.FailureReason.INFRA_FAILURE |
433 elif state == 'BOT_DIED' or result.get('internal_failure'): | 433 elif state == 'BOT_DIED' or result.get('internal_failure'): |
434 build.result = model.BuildResult.FAILURE | 434 build.result = model.BuildResult.FAILURE |
435 build.failure_reason = model.FailureReason.INFRA_FAILURE | 435 build.failure_reason = model.FailureReason.INFRA_FAILURE |
436 elif result.get('failure'): | 436 elif result.get('failure'): |
437 build.result = model.BuildResult.FAILURE | 437 build.result = model.BuildResult.FAILURE |
438 build.failure_reason = model.FailureReason.BUILD_FAILURE | 438 build.failure_reason = model.FailureReason.BUILD_FAILURE |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 def _extend_unique(target, items): | 683 def _extend_unique(target, items): |
684 for x in items: | 684 for x in items: |
685 if x not in target: # pragma: no branch | 685 if x not in target: # pragma: no branch |
686 target.append(x) | 686 target.append(x) |
687 | 687 |
688 | 688 |
689 class TaskToken(tokens.TokenKind): | 689 class TaskToken(tokens.TokenKind): |
690 expiration_sec = 60 * 60 * 24 # 24 hours. | 690 expiration_sec = 60 * 60 * 24 # 24 hours. |
691 secret_key = auth.SecretKey('swarming_task_token', scope='local') | 691 secret_key = auth.SecretKey('swarming_task_token', scope='local') |
692 version = 1 | 692 version = 1 |
OLD | NEW |