Chromium Code Reviews| Index: appengine/findit/waterfall/monitor_try_job_pipeline.py |
| diff --git a/appengine/findit/waterfall/monitor_try_job_pipeline.py b/appengine/findit/waterfall/monitor_try_job_pipeline.py |
| index 62c4093c4a89e974ee49f10b8733a23edcbe6c42..477a938875fc55b4f4182b4592d05e071f14d08b 100644 |
| --- a/appengine/findit/waterfall/monitor_try_job_pipeline.py |
| +++ b/appengine/findit/waterfall/monitor_try_job_pipeline.py |
| @@ -110,20 +110,24 @@ class MonitorTryJobPipeline(BasePipeline): |
| def _UpdateTryJobMetadata(try_job_data, start_time, buildbucket_build, |
| buildbucket_error, timed_out): |
| buildbucket_response = {} |
| + |
| if buildbucket_build: |
| - try_job_data.request_time = MonitorTryJobPipeline._MicrosecondsToDatetime( |
| - buildbucket_build.request_time) |
| + try_job_data.request_time = ( |
| + try_job_data.request_time or |
| + MonitorTryJobPipeline._MicrosecondsToDatetime( |
| + buildbucket_build.request_time)) |
| # If start_time is unavailable, fallback to request_time. |
| try_job_data.start_time = start_time or try_job_data.request_time |
| try_job_data.end_time = MonitorTryJobPipeline._MicrosecondsToDatetime( |
| buildbucket_build.end_time) |
| try_job_data.number_of_commits_analyzed = len( |
| buildbucket_build.report.get('result', {})) |
| - try_job_data.try_job_url = buildbucket_build.url |
| try_job_data.regression_range_size = buildbucket_build.report.get( |
| 'metadata', {}).get('regression_range_size') |
| - try_job_data.last_buildbucket_response = buildbucket_build.response |
| + try_job_data.try_job_url = ( |
| + try_job_data.try_job_url or buildbucket_build.url) |
|
stgao
2016/04/27 17:34:33
Why we don't use the one from buildbucket?
lijeffrey
2016/04/27 22:21:03
In case it's already set from line 229 when the bu
|
| buildbucket_response = buildbucket_build.response |
| + try_job_data.last_buildbucket_response = buildbucket_response |
| error_dict, error_code = MonitorTryJobPipeline._GetError( |
| buildbucket_response, buildbucket_error, timed_out) |
| @@ -180,13 +184,7 @@ class MonitorTryJobPipeline(BasePipeline): |
| # TODO(chanli): Make sure total wait time equals to timeout_hours |
| # regardless of retries. |
| deadline = time.time() + timeout_hours * 60 * 60 |
| - try_job_data = (WfTryJobData.Get(try_job_id) or |
| - WfTryJobData.Create(try_job_id)) |
| - try_job_data.master_name = master_name |
| - try_job_data.builder_name = builder_name |
| - try_job_data.build_number = build_number |
| - try_job_data.try_job_type = try_job_type |
| - |
| + try_job_data = WfTryJobData.Get(try_job_id) |
| already_set_started = False |
| start_time = None |
| while True: |
| @@ -222,6 +220,15 @@ class MonitorTryJobPipeline(BasePipeline): |
| self._UpdateTryJobResult( |
| BuildbucketBuild.STARTED, master_name, builder_name, build_number, |
| try_job_type, try_job_id, build.url) |
| + |
| + # Update as much try job metadata as soon as possible to avoid data |
| + # loss in case of errors. |
| + try_job_data.start_time = start_time |
| + try_job_data.request_time = ( |
| + MonitorTryJobPipeline._MicrosecondsToDatetime(build.request_time)) |
| + try_job_data.try_job_url = build.url |
| + try_job_data.put() |
| + |
| already_set_started = True |
| if time.time() > deadline: # pragma: no cover |