Index: pending_manager.py |
diff --git a/pending_manager.py b/pending_manager.py |
index b8b176b1d8d0a05bae89ad1e4a0787487b65c1b3..c392a91d0941dbf27d651cbd31f41f0e58e35572 100644 |
--- a/pending_manager.py |
+++ b/pending_manager.py |
@@ -197,13 +197,8 @@ class PendingManager(object): |
# are str due to json support. |
if pending.issue not in new_issues: |
logging.info('Flushing issue %d' % pending.issue) |
- self.context.status.send( |
- pending, |
- { 'verification': 'abort', |
- 'payload': { |
- 'output': 'CQ bit was unchecked on CL. Ignoring.' }}) |
pending.get_state = lambda: base.IGNORED |
- self._discard_pending(pending, None) |
+ self._discard_pending(pending, 'CQ bit was unchecked on CL. Ignoring.') |
# Find new issues. |
for issue_id in new_issues: |
@@ -271,7 +266,10 @@ class PendingManager(object): |
pending.issue, missing, pending.get_state())) |
self._verify_pending(pending) |
except base.DiscardPending as e: |
- self._discard_pending(e.pending, e.status) |
+ message = e.status |
+ if not message: |
+ message = 'process_new_pending_commit: ' + self.FAILED_NO_MESSAGE |
+ self._discard_pending(e.pending, message) |
def update_status(self): |
"""Updates the status for each pending commit verifier.""" |
@@ -283,7 +281,10 @@ class PendingManager(object): |
except base.DiscardPending as e: |
# It's not efficient since it takes a full loop for each pending |
# commit to discard. |
- self._discard_pending(e.pending, e.status) |
+ message = e.status |
+ if not message: |
+ message = 'update_status: ' + self.FAILED_NO_MESSAGE |
+ self._discard_pending(e.pending, message) |
for pending in self.queue.iterate(): |
why_not = pending.why_not() |
@@ -299,8 +300,10 @@ class PendingManager(object): |
for pending in self.queue.iterate(): |
state = pending.get_state() |
if state == base.FAILED: |
- self._discard_pending( |
- pending, pending.error_message() or self.FAILED_NO_MESSAGE) |
+ message = pending.error_message() |
+ if not message: |
+ message = 'scan_results(FAILED): ' + self.FAILED_NO_MESSAGE |
+ self._discard_pending(pending, message) |
elif state == base.SUCCEEDED: |
if self._throttle(pending): |
continue |
@@ -316,9 +319,13 @@ class PendingManager(object): |
self._commit_patch(pending) |
except base.DiscardPending as e: |
- self._discard_pending(e.pending, e.status) |
+ message = e.status |
+ if not message: |
+ message = 'scan_results(discard): ' + self.FAILED_NO_MESSAGE |
+ self._discard_pending(e.pending, message) |
except Exception as e: |
- self._discard_pending(pending, self.INTERNAL_EXCEPTION) |
+ message = 'scan_result(Exception): ' + self.INTERNAL_EXCEPTION |
+ self._discard_pending(pending, message) |
raise |
else: |
# When state is IGNORED, we need to keep this issue so it's not fetched |
@@ -423,6 +430,7 @@ class PendingManager(object): |
def _discard_pending(self, pending, message): |
"""Discards a pending commit. Attach an optional message to the review.""" |
logging.debug('_discard_pending(%s, %s)', pending.issue, message) |
+ msg = message or self.FAILED_NO_MESSAGE |
try: |
try: |
if pending.get_state() != base.IGNORED: |
@@ -431,24 +439,23 @@ class PendingManager(object): |
except urllib2.HTTPError as e: |
logging.error( |
'Failed to set the flag to False for %s with message %s' % ( |
- pending.pending_name(), message)) |
+ pending.pending_name(), msg)) |
traceback.print_stack() |
logging.error(str(e)) |
errors.send_stack(e) |
- if message: |
- try: |
- self.context.rietveld.add_comment(pending.issue, message) |
- except urllib2.HTTPError as e: |
- logging.error( |
- 'Failed to add comment for %s with message %s' % ( |
- pending.pending_name(), message)) |
- traceback.print_stack() |
- errors.send_stack(e) |
- self.context.status.send( |
- pending, |
- { 'verification': 'abort', |
- 'payload': { |
- 'output': message }}) |
+ try: |
+ self.context.rietveld.add_comment(pending.issue, msg) |
+ except urllib2.HTTPError as e: |
+ logging.error( |
+ 'Failed to add comment for %s with message %s' % ( |
+ pending.pending_name(), msg)) |
+ traceback.print_stack() |
+ errors.send_stack(e) |
+ self.context.status.send( |
+ pending, |
+ { 'verification': 'abort', |
+ 'payload': { |
+ 'output': msg }}) |
finally: |
# Most importantly, remove the PendingCommit from the queue. |
self.queue.remove(pending.issue) |
@@ -527,7 +534,10 @@ class PendingManager(object): |
out += '\n%s' % stdout |
raise base.DiscardPending(pending, out) |
except base.DiscardPending as e: |
- self._discard_pending(e.pending, e.status) |
+ message = e.status |
+ if not message: |
+ message = '_commit_patch: ' + self.FAILED_NO_MESSAGE |
+ self._discard_pending(e.pending, message) |
def _throttle(self, pending): |
"""Returns True if a commit should be delayed.""" |