| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from datetime import datetime | 5 from datetime import datetime |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from common import buildbucket_client | 8 from common import buildbucket_client |
| 9 from common.buildbucket_client import BuildbucketBuild | 9 from common.buildbucket_client import BuildbucketBuild |
| 10 from model import wf_analysis_status | 10 from model import wf_analysis_status |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 # Arguments number differs from overridden method - pylint: disable=W0221 | 92 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 93 # TODO(chanli): Handle try job for test failures later. | 93 # TODO(chanli): Handle try job for test failures later. |
| 94 def run( | 94 def run( |
| 95 self, master_name, builder_name, build_number, try_job_type, try_job_id): | 95 self, master_name, builder_name, build_number, try_job_type, try_job_id): |
| 96 assert try_job_id | 96 assert try_job_id |
| 97 | 97 |
| 98 timeout_hours = 5 | 98 timeout_hours = 5 |
| 99 deadline = time.time() + timeout_hours * 60 * 60 | 99 deadline = time.time() + timeout_hours * 60 * 60 |
| 100 try_job_data = (WfTryJobData.Get(try_job_id) or | 100 try_job_data = (WfTryJobData.Get(try_job_id) or |
| 101 WfTryJobData.Create(try_job_id)) | 101 WfTryJobData.Create(try_job_id)) |
| 102 try_job_data.master_name = master_name |
| 103 try_job_data.builder_name = builder_name |
| 104 try_job_data.try_job_type = try_job_type |
| 102 | 105 |
| 103 already_set_started = False | 106 already_set_started = False |
| 104 start_time = None | 107 start_time = None |
| 105 while True: | 108 while True: |
| 106 error, build = buildbucket_client.GetTryJobs([try_job_id])[0] | 109 error, build = buildbucket_client.GetTryJobs([try_job_id])[0] |
| 107 if error: # pragma: no cover | 110 if error: # pragma: no cover |
| 108 self._UpdateTryJobMetadataForBuildError(try_job_data, error) | 111 self._UpdateTryJobMetadataForBuildError(try_job_data, error) |
| 109 raise pipeline.Retry( | 112 raise pipeline.Retry( |
| 110 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) | 113 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) |
| 111 elif build.status == BuildbucketBuild.COMPLETED: | 114 elif build.status == BuildbucketBuild.COMPLETED: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 131 if time.time() > deadline: # pragma: no cover | 134 if time.time() > deadline: # pragma: no cover |
| 132 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) | 135 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) |
| 133 try_job_result.status = wf_analysis_status.ERROR | 136 try_job_result.status = wf_analysis_status.ERROR |
| 134 try_job_result.put() | 137 try_job_result.put() |
| 135 self._UpdateTryJobMetadataForCompletedBuild( | 138 self._UpdateTryJobMetadataForCompletedBuild( |
| 136 try_job_data, build, start_time, timed_out=True) | 139 try_job_data, build, start_time, timed_out=True) |
| 137 # Explicitly abort the whole pipeline. | 140 # Explicitly abort the whole pipeline. |
| 138 raise pipeline.Abort( | 141 raise pipeline.Abort( |
| 139 'Try job %s timed out after %d hours.' % ( | 142 'Try job %s timed out after %d hours.' % ( |
| 140 try_job_id, timeout_hours)) | 143 try_job_id, timeout_hours)) |
| OLD | NEW |