Merge "gerrit: handle POST 400 errors and don't retry"

This commit is contained in:
Zuul 2021-10-13 22:41:00 +00:00 committed by Gerrit Code Review
commit 3066cbf9d6
1 changed files with 18 additions and 0 deletions

View File

@ -57,6 +57,10 @@ class HTTPConflictException(Exception):
message = "Received response 409" message = "Received response 409"
class HTTPBadRequestException(Exception):
pass
class GerritChangeCache(AbstractChangeCache): class GerritChangeCache(AbstractChangeCache):
log = logging.getLogger("zuul.driver.GerritChangeCache") log = logging.getLogger("zuul.driver.GerritChangeCache")
@ -713,6 +717,8 @@ class GerritConnection(ZKChangeCacheMixin, BaseConnection):
self.iolog.debug('Received: %s %s' % (r.status_code, r.text,)) self.iolog.debug('Received: %s %s' % (r.status_code, r.text,))
if r.status_code == 409: if r.status_code == 409:
raise HTTPConflictException() raise HTTPConflictException()
if r.status_code == 400:
raise HTTPBadRequestException('Received response 400: %s' % r.text)
elif r.status_code != 200: elif r.status_code != 200:
raise Exception("Received response %s" % (r.status_code,)) raise Exception("Received response %s" % (r.status_code,))
ret = None ret = None
@ -1188,6 +1194,10 @@ class GerritConnection(ZKChangeCacheMixin, BaseConnection):
except HTTPConflictException: except HTTPConflictException:
log.exception("Conflict submitting check data to gerrit.") log.exception("Conflict submitting check data to gerrit.")
break break
except HTTPBadRequestException:
log.exception(
"Bad request submitting check data to gerrit.")
break
except Exception: except Exception:
log.exception("Error submitting check data to gerrit, " log.exception("Error submitting check data to gerrit, "
"attempt %s", x) "attempt %s", x)
@ -1235,6 +1245,10 @@ class GerritConnection(ZKChangeCacheMixin, BaseConnection):
except HTTPConflictException: except HTTPConflictException:
log.exception("Conflict submitting data to gerrit.") log.exception("Conflict submitting data to gerrit.")
break break
except HTTPBadRequestException:
log.exception(
"Bad request submitting check data to gerrit.")
break
except Exception: except Exception:
log.exception( log.exception(
"Error submitting data to gerrit, attempt %s", x) "Error submitting data to gerrit, attempt %s", x)
@ -1247,6 +1261,10 @@ class GerritConnection(ZKChangeCacheMixin, BaseConnection):
except HTTPConflictException: except HTTPConflictException:
log.exception("Conflict submitting data to gerrit.") log.exception("Conflict submitting data to gerrit.")
break break
except HTTPBadRequestException:
log.exception(
"Bad request submitting check data to gerrit.")
break
except Exception: except Exception:
log.exception( log.exception(
"Error submitting data to gerrit, attempt %s", x) "Error submitting data to gerrit, attempt %s", x)