summaryrefslogtreecommitdiff
path: root/zuul
diff options
context:
space:
mode:
authorPaul Belanger <pabelanger@redhat.com>2019-06-12 05:52:07 -0400
committerPaul Belanger <pabelanger@redhat.com>2019-06-12 12:09:57 -0400
commit449947bcdfd66453c38975781709ef3be0639107 (patch)
tree9d0ab9bf67b76b67162def35894c5a73e3bc3ddf /zuul
parent1a176ef18780f3c3dad60481c37f9d20b0155f2b (diff)
downloadzuul-449947bcdfd66453c38975781709ef3be0639107.tar.gz
Add retry logic to github event handler
Try up to 5 times to process an event on github, this is to address the following exception: 2019-06-12 08:46:22,075 ERROR zuul.GithubEventConnector: [delivery: fa0be202-8ced-11e9-80ad-d97f703c5a03] Exception when handling event: Traceback (most recent call last): File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/zuul/driver/github/githubconnection.py", line 253, in _handle_event event = method() File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/zuul/driver/github/githubconnection.py", line 407, in _event_status self.body['sha'], project, self.log) File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/zuul/driver/github/githubconnection.py", line 1226, in getPullBySha direction='asc'): File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/github3/structs.py", line 89, in __iter__ json = self._get_json(response) File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/github3/structs.py", line 136, in _get_json return self._json(response, 200) File "/opt/venv/zuul-3.8.1/lib/python3.6/site-packages/github3/models.py", line 156, in _json raise exceptions.error_for(response) github3.exceptions.ServerError: 502 Server Error Change-Id: I603bc894667187312421493f9337eec545100b78 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
Diffstat (limited to 'zuul')
-rw-r--r--zuul/driver/github/githubconnection.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py
index ae7626ead..ad2988a96 100644
--- a/zuul/driver/github/githubconnection.py
+++ b/zuul/driver/github/githubconnection.py
@@ -256,12 +256,21 @@ class GithubEventProcessor(object):
return
self.log.debug("Handling %s event", self.event_type)
-
+ event = None
try:
- event = method()
+ for retry in range(5):
+ try:
+ event = method()
+ break
+ except github3.exceptions.ServerError:
+ self.log.exception(
+ "Failed handling %s event; retrying", self.event_type)
+ time.sleep(1)
except Exception:
+ # NOTE(pabelanger): We should report back to the PR we could
+ # not process the event, to give the user a chance to
+ # retrigger.
self.log.exception('Exception when handling event:')
- event = None
if event:
event.delivery = self.delivery