autoland: treat a 404 from a pingback as a fatal error (
bug 1434166) r?gps
A 404 from a pingback means the other system no longer has the record for the
autoland request; treat it as a fatal error instead of entering into an
infinite loop of transient retries.
MozReview-Commit-ID: 6TuqQFn2aQa
--- a/autoland/autoland/autoland.py
+++ b/autoland/autoland/autoland.py
@@ -264,18 +264,18 @@ def handle_pending_mozreview_updates(dbc
on (Transplant.id = MozreviewUpdate.transplant_id)
limit %(limit)s
"""
cursor.execute(query, {'limit': MOZREVIEW_COMMENT_LIMIT})
mozreview_pingback = mozreview.MozReviewPingback()
lando_pingback = lando.LandoPingback()
- updated = []
- all_posted = True
+ completed = []
+ failed = False
for row in cursor.fetchall():
update_id, transplant_id, request, data = row
# Validate the pingback hostname is still present in config.json.
pingback_url = request.get('pingback_url')
hostname = urlparse.urlparse(pingback_url).hostname
if hostname == 'localhost':
@@ -305,35 +305,45 @@ def handle_pending_mozreview_updates(dbc
pingback_url = None
# Update the requester if required.
if pingback_url:
logger.info('trying to post %s update to: %s for request: %s' %
(pingback.name, pingback_url, transplant_id))
status_code, text = pingback.update(pingback_url, data)
+
if status_code == 200:
- updated.append([update_id])
+ # Success.
+ completed.append([update_id])
+
+ elif status_code == 404:
+ # Submitting system "forgot" about this request; delete it
+ # so we can continuing processing pending updates.
+ logger.info('failed: %s - %s' % (status_code, text))
+ completed.append([update_id])
+
else:
+ # Treat anything else as a transient failure.
logger.info('failed: %s - %s' % (status_code, text))
- all_posted = False
+ failed = True
break
else:
- updated.append([update_id])
+ completed.append([update_id])
- if updated:
+ if completed:
query = """
delete from MozreviewUpdate
where id=%s
"""
- cursor.executemany(query, updated)
+ cursor.executemany(query, completed)
dbconn.commit()
- return all_posted
+ return not failed
def get_dbconn(dsn):
dbconn = None
while not dbconn:
try:
dbconn = psycopg2.connect(dsn)
except psycopg2.OperationalError: