Merge "Ignore 500 errors when requesting pr files"
This commit is contained in:
commit
a366c05cee
|
@ -23,6 +23,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from json.decoder import JSONDecodeError
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import cachecontrol
|
import cachecontrol
|
||||||
|
@ -228,6 +229,23 @@ class GithubRetryHandler:
|
||||||
if not 500 <= response.status_code < 600:
|
if not 500 <= response.status_code < 600:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = response.json()
|
||||||
|
errors = data.get('errors', [])
|
||||||
|
for error in errors:
|
||||||
|
resource = error.get('resource')
|
||||||
|
field = error.get('field')
|
||||||
|
code = error.get('code')
|
||||||
|
if (resource == 'PullRequest' and
|
||||||
|
field == 'diff' and
|
||||||
|
code == 'not_available'):
|
||||||
|
# Github responds with 500 if the diff is too large so we
|
||||||
|
# need to ignore it because retries won't help.
|
||||||
|
return
|
||||||
|
except JSONDecodeError:
|
||||||
|
# If there is no json just continue with retry handling.
|
||||||
|
pass
|
||||||
|
|
||||||
if hasattr(response.request, 'zuul_retry_count'):
|
if hasattr(response.request, 'zuul_retry_count'):
|
||||||
retry_count = response.request.zuul_retry_count
|
retry_count = response.request.zuul_retry_count
|
||||||
retry_delay = min(response.request.zuul_retry_delay * 2,
|
retry_delay = min(response.request.zuul_retry_delay * 2,
|
||||||
|
@ -1420,7 +1438,9 @@ class GithubConnection(BaseConnection):
|
||||||
# Github's pull requests files API only returns at max
|
# Github's pull requests files API only returns at max
|
||||||
# the first 300 changed files of a PR in alphabetical order.
|
# the first 300 changed files of a PR in alphabetical order.
|
||||||
# https://developer.github.com/v3/pulls/#list-pull-requests-files
|
# https://developer.github.com/v3/pulls/#list-pull-requests-files
|
||||||
if len(change.files) < change.pr.get('changed_files', 0):
|
if change.files is None:
|
||||||
|
log.warning("Got no files of PR.")
|
||||||
|
elif len(change.files) < change.pr.get('changed_files', 0):
|
||||||
log.warning("Got only %s files but PR has %s files.",
|
log.warning("Got only %s files but PR has %s files.",
|
||||||
len(change.files),
|
len(change.files),
|
||||||
change.pr.get('changed_files', 0))
|
change.pr.get('changed_files', 0))
|
||||||
|
@ -1610,7 +1630,7 @@ class GithubConnection(BaseConnection):
|
||||||
self.log.warning("Failed to get list of files from Github. "
|
self.log.warning("Failed to get list of files from Github. "
|
||||||
"Using empty file list to trigger update "
|
"Using empty file list to trigger update "
|
||||||
"via the merger: %s", exc)
|
"via the merger: %s", exc)
|
||||||
pr['files'] = []
|
pr['files'] = None
|
||||||
|
|
||||||
labels = [l['name'] for l in pr['labels']]
|
labels = [l['name'] for l in pr['labels']]
|
||||||
pr['labels'] = labels
|
pr['labels'] = labels
|
||||||
|
|
Loading…
Reference in New Issue