Simplify change reporting to handle errors better

If Zuul runs into an SSH error (or other low level issue) when reporting
change results back to Gerrit it can get itself into a loop where it
will be unable to finish reporting a change due to internal inconsistent
state.

Modify the reporting process to flow in such a way that if errors
outside of zuul's control eventually go away the retry loop for
reporting will succeed and zuul can move on.

Specifically check and flip the 'reported' flag in one place to make the
logical flow of reporting simpler to understand. This has a side effect
of making it possible to retry reporting multiple times and as long as
the network works reporting should succeed.

Change-Id: I2023f472be8ca0b606f680418006d3a6c2239061
Fixes-bug: 1349486
This commit is contained in:
Clark Boylan 2014-07-28 10:12:25 -07:00
parent 145d9d7ae6
commit f7dc4da5c4
1 changed files with 4 additions and 7 deletions

View File

@ -1405,12 +1405,12 @@ class BasePipelineManager(object):
self.pipeline.setUnableToMerge(item)
def reportItem(self, item):
if item.reported:
raise Exception("Already reported change %s" % item.change)
ret = self._reportItem(item)
if not item.reported:
# _reportItem() returns True if it failed to report.
item.reported = not self._reportItem(item)
if self.changes_merge:
succeeded = self.pipeline.didAllJobsSucceed(item)
merged = (not ret)
merged = item.reported
if merged:
merged = self.pipeline.trigger.isMerged(item.change,
item.change.branch)
@ -1430,8 +1430,6 @@ class BasePipelineManager(object):
(change_queue, change_queue.window))
def _reportItem(self, item):
if item.reported:
return 0
self.log.debug("Reporting change %s" % item.change)
ret = True # Means error as returned by trigger.report
if self.pipeline.didAllJobsSucceed(item):
@ -1444,7 +1442,6 @@ class BasePipelineManager(object):
else:
actions = self.pipeline.failure_actions
item.setReportedResult('FAILURE')
item.reported = True
if actions:
report = self.formatReport(item)
try: