Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: appengine/findit/waterfall/monitor_try_job_pipeline.py

Issue 2260313003: [Findit] Capture and store latest buildbucket response with each query (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 json 6 import json
7 import time 7 import time
8 8
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 10
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 allowed_response_error_times = max_error_times 199 allowed_response_error_times = max_error_times
200 200
201 # TODO(chanli): Make sure total wait time equals to timeout_hours 201 # TODO(chanli): Make sure total wait time equals to timeout_hours
202 # regardless of retries. 202 # regardless of retries.
203 deadline = time.time() + timeout_hours * 60 * 60 203 deadline = time.time() + timeout_hours * 60 * 60
204 try_job_data = WfTryJobData.Get(try_job_id) 204 try_job_data = WfTryJobData.Get(try_job_id)
205 already_set_started = False 205 already_set_started = False
206 start_time = None 206 start_time = None
207 while True: 207 while True:
208 error, build = buildbucket_client.GetTryJobs([try_job_id])[0] 208 error, build = buildbucket_client.GetTryJobs([try_job_id])[0]
209
209 if error: 210 if error:
210 if allowed_response_error_times > 0: 211 if allowed_response_error_times > 0:
211 allowed_response_error_times -= 1 212 allowed_response_error_times -= 1
212 pipeline_wait_seconds += default_pipeline_wait_seconds 213 pipeline_wait_seconds += default_pipeline_wait_seconds
213 else: # pragma: no cover 214 else: # pragma: no cover
214 # Buildbucket has responded error more than 5 times, retry pipeline. 215 # Buildbucket has responded error more than 5 times, retry pipeline.
215 _UpdateTryJobMetadata(try_job_data, start_time, build, error, False) 216 _UpdateTryJobMetadata(try_job_data, start_time, build, error, False)
216 raise pipeline.Retry( 217 raise pipeline.Retry(
217 'Error "%s" occurred. Reason: "%s"' % (error.message, 218 'Error "%s" occurred. Reason: "%s"' % (error.message,
218 error.reason)) 219 error.reason))
(...skipping 27 matching lines...) Expand all
246 247
247 already_set_started = True 248 already_set_started = True
248 249
249 if time.time() > deadline: # pragma: no cover 250 if time.time() > deadline: # pragma: no cover
250 _UpdateTryJobMetadata(try_job_data, start_time, build, error, True) 251 _UpdateTryJobMetadata(try_job_data, start_time, build, error, True)
251 # Explicitly abort the whole pipeline. 252 # Explicitly abort the whole pipeline.
252 raise pipeline.Abort( 253 raise pipeline.Abort(
253 'Try job %s timed out after %d hours.' % ( 254 'Try job %s timed out after %d hours.' % (
254 try_job_id, timeout_hours)) 255 try_job_id, timeout_hours))
255 256
257 # Ensure last_buildbucket_response is always the most recent
258 # whenever available during intermediate queries.
259 if build and build.response:
260 try_job_data.last_buildbucket_response = build.response
stgao 2016/08/19 21:44:36 nit: not update datastore if the current response
261 try_job_data.put()
262
256 time.sleep(pipeline_wait_seconds) # pragma: no cover 263 time.sleep(pipeline_wait_seconds) # pragma: no cover
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698