Merge lp:~julian-edwards/launchpad/reduce-oops-count-on-uploads-bug-673590 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 11947
Proposed branch: lp:~julian-edwards/launchpad/reduce-oops-count-on-uploads-bug-673590
Merge into: lp:launchpad
Diff against target: 57 lines (+18/-7)
2 files modified
lib/lp/archiveuploader/nascentupload.py (+17/-6)
lib/lp/archiveuploader/tests/nascentupload.txt (+1/-1)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/reduce-oops-count-on-uploads-bug-673590
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Julian Edwards (community) code Approve
Review via email: mp+41296@code.launchpad.net

Commit message

Change the log level of QueueInconsistentStateError during upload processing so that the logger handler for cron scripts doesn't generate OOPSes.

Description of the change

Change the log level of QueueInconsistentStateError during upload so that the logger handler for cron scripts doesn't generate OOPSes.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve (code)
Revision history for this message
Robert Collins (lifeless) wrote :

Postreview ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/nascentupload.py'
2--- lib/lp/archiveuploader/nascentupload.py 2010-11-05 14:17:11 +0000
3+++ lib/lp/archiveuploader/nascentupload.py 2010-11-19 12:53:17 +0000
4@@ -42,6 +42,7 @@
5 from lp.registry.interfaces.sourcepackage import SourcePackageFileType
6 from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
7 from lp.soyuz.interfaces.archive import MAIN_ARCHIVE_PURPOSES
8+from lp.soyuz.interfaces.queue import QueueInconsistentStateError
9
10
11 PARTNER_COMPONENT_NAME = 'partner'
12@@ -860,16 +861,26 @@
13
14 except (SystemExit, KeyboardInterrupt):
15 raise
16+ except QueueInconsistentStateError, e:
17+ # A QueueInconsistentStateError is expected if the rejection
18+ # is a routine rejection due to a bad package upload.
19+ # Log at info level so LaunchpadCronScript doesn't generate an
20+ # OOPS.
21+ func = self.logger.info
22+ return self._reject_with_logging(e, notify, func)
23 except Exception, e:
24 # Any exception which occurs while processing an accept will
25 # cause a rejection to occur. The exception is logged in the
26 # reject message rather than being swallowed up.
27- self.reject("%s" % e)
28- # Let's log tracebacks for uncaught exceptions ...
29- self.logger.error(
30- 'Exception while accepting:\n %s' % e, exc_info=True)
31- self.do_reject(notify)
32- return False
33+ func = self.logger.error
34+ return self._reject_with_logging(e, notify, func)
35+
36+ def _reject_with_logging(self, error, notify, log_func):
37+ """Helper to reject an upload and log it using the logger function."""
38+ self.reject("%s" % error)
39+ log_func('Exception while accepting:\n %s' % error, exc_info=True)
40+ self.do_reject(notify)
41+ return False
42
43 def do_reject(self, notify=True):
44 """Reject the current upload given the reason provided."""
45
46=== modified file 'lib/lp/archiveuploader/tests/nascentupload.txt'
47--- lib/lp/archiveuploader/tests/nascentupload.txt 2010-11-06 12:31:55 +0000
48+++ lib/lp/archiveuploader/tests/nascentupload.txt 2010-11-19 12:53:17 +0000
49@@ -455,7 +455,7 @@
50 The upload will be rejected.
51
52 >>> success = ed_src_dup.do_accept()
53- ERROR: Exception while accepting:
54+ INFO: Exception while accepting:
55 The source ed - 0.2-20 is already accepted in ubuntu/hoary and you
56 cannot upload the same version within the same distribution. You
57 have to modify the source version and re-upload.