Merge lp:~wgrant/launchpad/bug-390543 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 12610
Proposed branch: lp:~wgrant/launchpad/bug-390543
Merge into: lp:launchpad
Diff against target: 269 lines (+30/-132)
3 files modified
lib/lp/bugs/doc/checkwatches-cli-switches.txt (+0/-2)
lib/lp/bugs/doc/checkwatches.txt (+30/-122)
lib/lp/bugs/scripts/checkwatches/core.py (+0/-8)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-390543
Reviewer Review Type Date Requested Status
Steve Kowalik (community) Approve
Review via email: mp+53568@code.launchpad.net

Commit message

[r=stevenk][bug=390543] Don't log OOPSes for UnknownBugTrackerTypeErrors.

Description of the change

UnknownBugTrackerTypeErrors are logged to BugWatchActivity and all have bugs filed, but they cause hundreds of OOPSes every day. They are known, non-critical issues, so this branch removes OOPS logging for them.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) wrote :

William has addressed my concerns on IRC.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/doc/checkwatches-cli-switches.txt'
--- lib/lp/bugs/doc/checkwatches-cli-switches.txt 2011-02-28 08:59:27 +0000
+++ lib/lp/bugs/doc/checkwatches-cli-switches.txt 2011-03-16 05:38:26 +0000
@@ -108,8 +108,6 @@
108 INFO Resetting 5 bug watches for bug tracker 'savannah'108 INFO Resetting 5 bug watches for bug tracker 'savannah'
109 INFO Updating 5 watches on bug tracker 'savannah'109 INFO Updating 5 watches on bug tracker 'savannah'
110 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE110 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
111 WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
112 (OOPS-...)
113 INFO 0 watches left to check on bug tracker 'savannah'111 INFO 0 watches left to check on bug tracker 'savannah'
114 INFO Time for this run...112 INFO Time for this run...
115113
116114
=== modified file 'lib/lp/bugs/doc/checkwatches.txt'
--- lib/lp/bugs/doc/checkwatches.txt 2011-03-10 02:15:00 +0000
+++ lib/lp/bugs/doc/checkwatches.txt 2011-03-16 05:38:26 +0000
@@ -14,90 +14,6 @@
14 >>> import transaction14 >>> import transaction
15 >>> transaction.commit()15 >>> transaction.commit()
1616
17We'll add a bug watch to the Gnu Savannah bug tracker so that
18checkwatches will try to get an ExternalBugTracker with which to update
19the watch.
20
21 >>> from canonical.config import config
22 >>> from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
23 >>> from canonical.testing.layers import LaunchpadZopelessLayer
24 >>> from lp.testing.factory import LaunchpadObjectFactory
25
26 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
27
28 >>> factory = LaunchpadObjectFactory()
29 >>> savannah = getUtility(ILaunchpadCelebrities).savannah_tracker
30 >>> bug_watch = factory.makeBugWatch(bugtracker=savannah)
31
32 >>> transaction.commit()
33 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
34
35 >>> import subprocess
36 >>> process = subprocess.Popen(
37 ... ['cronscripts/checkwatches.py', '-v'],
38 ... stdin=subprocess.PIPE, stdout=subprocess.PIPE,
39 ... stderr=subprocess.PIPE)
40 >>> (out, err) = process.communicate()
41 >>> out
42 ''
43 >>> process.returncode
44 0
45
46 >>> print err
47 DEBUG ...
48 DEBUG No global batch size specified.
49 DEBUG Skipping updating Ubuntu Bugzilla watches.
50 DEBUG No watches to update on http://bugs.debian.org
51 DEBUG No watches to update on mailto:bugs@example.com
52 DEBUG No watches to update on http://bugzilla.gnome.org/
53 DEBUG No watches to update on http://bugzilla.gnome.org/bugs
54 DEBUG No watches to update on https://bugzilla.mozilla.org/
55 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
56 WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
57 (OOPS-...)
58 DEBUG No watches to update on http://sourceforge.net/
59 INFO Time for this run: ... seconds.
60 DEBUG Removing lock file:...
61 <BLANKLINE>
62
63OOPSes reported by the checkwatches process are raised using the
64CheckWatchesErrorUtility. The errors have 'CW' in their oops prefix
65and their type is 'BugWatchUpdateWarning'.
66
67 >>> from lp.bugs.scripts.checkwatches.base import (
68 ... CheckWatchesErrorUtility)
69 >>> error_utility = CheckWatchesErrorUtility()
70 >>> report = error_utility.getLastOopsReport()
71 >>> report.id
72 'OOPS-...TCW...'
73 >>> report.type
74 'BugWatchUpdateWarning'
75
76 >>> from sys import stdout
77 >>> def dump_last_oops():
78 ... error_utility.getLastOopsReport().write(stdout)
79
80 >>> dump_last_oops()
81 Oops-Id: OOPS-...TCW...
82 Exception-Type: BugWatchUpdateWarning
83 Exception-Value: ExternalBugtracker for BugTrackerType 'SAVANE' ...
84 Date: ...
85 Page-Id:
86 Branch: ...
87 Revision: ...
88 User: None
89 URL: None
90 Duration: ...
91 Informational: False
92 <BLANKLINE>
93 error-explanation=ExternalBugtracker for ... is not known.
94 ...SELECT BugTracker...
95 ...Transaction completed, status: Active...
96 Traceback (most recent call last):
97 ...
98 BugWatchUpdateWarning: ExternalBugtracker for BugTrackerType 'SAVANE'
99 is not known.
100
101We set a default timeout on checkwatches to 30 seconds. In order to test17We set a default timeout on checkwatches to 30 seconds. In order to test
102this, we can monkey-patch urllib2.urlopen so that it always raises a18this, we can monkey-patch urllib2.urlopen so that it always raises a
103timeout and call the checkwatches cronscript machinery directly.19timeout and call the checkwatches cronscript machinery directly.
@@ -105,6 +21,8 @@
105First, we create some bug watches to test with:21First, we create some bug watches to test with:
10622
107 >>> from datetime import datetime23 >>> from datetime import datetime
24 >>> from canonical.launchpad.interfaces.launchpad import (
25 ... ILaunchpadCelebrities)
108 >>> from lp.bugs.interfaces.bug import IBugSet26 >>> from lp.bugs.interfaces.bug import IBugSet
109 >>> from lp.bugs.interfaces.bugtracker import BugTrackerType27 >>> from lp.bugs.interfaces.bugtracker import BugTrackerType
110 >>> from lp.bugs.model.bugtracker import BugTracker28 >>> from lp.bugs.model.bugtracker import BugTracker
@@ -144,7 +62,10 @@
144 >>> import urllib262 >>> import urllib2
145 >>> urlopen = urllib2.urlopen63 >>> urlopen = urllib2.urlopen
14664
147 >>> transaction.commit()65 >>> from lp.bugs.scripts.checkwatches.base import (
66 ... CheckWatchesErrorUtility)
67 >>> error_utility = CheckWatchesErrorUtility()
68 >>> last_oops_id = error_utility.getLastOopsReport().id
148 >>> def do_not_urlopen(url=None, data=None):69 >>> def do_not_urlopen(url=None, data=None):
149 ... raise socket.timeout("Connection timed out.")70 ... raise socket.timeout("Connection timed out.")
150 >>> try:71 >>> try:
@@ -154,11 +75,8 @@
154 ... bug_tracker_names=[example_bug_tracker_name])75 ... bug_tracker_names=[example_bug_tracker_name])
155 ... finally:76 ... finally:
156 ... urllib2.urlopen = urlopen77 ... urllib2.urlopen = urlopen
157 >>> dump_last_oops()78 >>> last_oops_id == error_utility.getLastOopsReport().id
158 Oops-Id: OOPS-...TCW...79 True
159 Exception-Type: BugWatchUpdateWarning
160 Exception-Value: ExternalBugtracker for BugTrackerType 'SAVANE' ...
161 ...
16280
163Errors that occur when updating a bug watch are recorded against that81Errors that occur when updating a bug watch are recorded against that
164bug watch. The timeout will be recorded against the bug watch we just82bug watch. The timeout will be recorded against the bug watch we just
@@ -196,8 +114,6 @@
196 ... finally:114 ... finally:
197 ... externalbugtracker.get_external_bugtracker = (115 ... externalbugtracker.get_external_bugtracker = (
198 ... real_get_external_bugtracker)116 ... real_get_external_bugtracker)
199 WARNING...:ExternalBugtracker for BugTrackerType 'ROUNDUP' is not
200 known. (OOPS-...)
201117
202The bug watch's last error type field will have been updated to reflect118The bug watch's last error type field will have been updated to reflect
203the error that was raised:119the error that was raised:
@@ -266,9 +182,12 @@
266called by the checkwatches script, which doesn't know or care about182called by the checkwatches script, which doesn't know or care about
267IBugTracker and instances thereof.183IBugTracker and instances thereof.
268184
269If we look at our Savannah bug tracker, we'll see that it's got one bug185Let's first create a watch on our Savannah bug tracker.
270watch.
271186
187 >>> from lp.testing.dbuser import dbuser
188 >>> savannah = getUtility(ILaunchpadCelebrities).savannah_tracker
189 >>> with dbuser('launchpad'):
190 ... bug_watch = factory.makeBugWatch(bugtracker=savannah)
272 >>> savannah.watches.count()191 >>> savannah.watches.count()
273 1192 1
274193
@@ -276,8 +195,7 @@
276that it looks as though it has been updated recently195that it looks as though it has been updated recently
277196
278 >>> login('test@canonical.com')197 >>> login('test@canonical.com')
279 >>> for watch in savannah.watches:198 >>> savannah.resetWatches()
280 ... watch.lastchecked = datetime.now(utc)
281199
282So our Savannah instance now has no watches that need checking.200So our Savannah instance now has no watches that need checking.
283201
@@ -300,8 +218,6 @@
300 INFO Resetting 1 bug watches for bug tracker 'savannah'218 INFO Resetting 1 bug watches for bug tracker 'savannah'
301 INFO Updating 1 watches on bug tracker 'savannah'219 INFO Updating 1 watches on bug tracker 'savannah'
302 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE220 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
303 WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
304 (OOPS-...)
305 INFO 0 watches left to check on bug tracker 'savannah'221 INFO 0 watches left to check on bug tracker 'savannah'
306222
307We can see that the Savannah bug watch has been updated recently. Also,223We can see that the Savannah bug watch has been updated recently. Also,
@@ -316,13 +232,10 @@
316If a bug tracker doesn't have any watches to update, forceUpdateAll()232If a bug tracker doesn't have any watches to update, forceUpdateAll()
317will ignore it.233will ignore it.
318234
319 >>> transaction.commit()235 >>> with dbuser('launchpad'):
320 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')236 ... login('test@canonical.com')
321 >>> login('test@canonical.com')237 ... empty_tracker = factory.makeBugTracker(
322 >>> empty_tracker = factory.makeBugTracker(238 ... 'http://example.com', BugTrackerType.ROUNDUP)
323 ... 'http://example.com', BugTrackerType.ROUNDUP)
324 >>> transaction.commit()
325 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
326 >>> empty_tracker_name = empty_tracker.name239 >>> empty_tracker_name = empty_tracker.name
327 >>> update_all(empty_tracker_name)240 >>> update_all(empty_tracker_name)
328 INFO Bug tracker 'auto-example.com' doesn't have any watches. Ignoring.241 INFO Bug tracker 'auto-example.com' doesn't have any watches. Ignoring.
@@ -336,11 +249,9 @@
336We'll add some more watches in order to demonstrate this.249We'll add some more watches in order to demonstrate this.
337250
338 >>> transaction.commit()251 >>> transaction.commit()
339 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')252 >>> with dbuser('launchpad'):
340 >>> for i in range(5):253 ... for i in range(5):
341 ... bug_watch = factory.makeBugWatch(bugtracker=empty_tracker)254 ... bug_watch = factory.makeBugWatch(bugtracker=empty_tracker)
342 >>> transaction.commit()
343 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
344255
345 >>> empty_tracker.watches.count()256 >>> empty_tracker.watches.count()
346 5257 5
@@ -443,13 +354,11 @@
443We'll generate a bug watch with which to test this. The bug watch must354We'll generate a bug watch with which to test this. The bug watch must
444be associated with at least one bug task to enable syncing.355be associated with at least one bug task to enable syncing.
445356
446 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')357 >>> with dbuser('launchpad'):
447 >>> login('foo.bar@canonical.com')358 ... login('foo.bar@canonical.com')
448 >>> bug_tracker = factory.makeBugTracker()359 ... bug_tracker = factory.makeBugTracker()
449 >>> bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)360 ... bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)
450 >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch361 ... bug_watch.bug.default_bugtask.bugwatch = bug_watch
451 >>> transaction.commit()
452 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
453362
454If we pass our UselessExternalBugTracker and the bug watch we just363If we pass our UselessExternalBugTracker and the bug watch we just
455generated to updateBugWatches we can see that its comments will be364generated to updateBugWatches we can see that its comments will be
@@ -469,8 +378,7 @@
469another bug, comments won't be synced and the bug won't be linked back378another bug, comments won't be synced and the bug won't be linked back
470to the remote bug.379to the remote bug.
471380
472 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')381 >>> with dbuser('launchpad'):
473 >>> bug_15 = getUtility(IBugSet).get(15)382 ... bug_15 = getUtility(IBugSet).get(15)
474 >>> bug_watch.bug.markAsDuplicate(bug_15)383 ... bug_watch.bug.markAsDuplicate(bug_15)
475384 ... updater.updateBugWatches(remote_system, [bug_watch], now=nowish)
476 >>> updater.updateBugWatches(remote_system, [bug_watch], now=nowish)
477385
=== modified file 'lib/lp/bugs/scripts/checkwatches/core.py'
--- lib/lp/bugs/scripts/checkwatches/core.py 2011-03-10 04:17:48 +0000
+++ lib/lp/bugs/scripts/checkwatches/core.py 2011-03-16 05:38:26 +0000
@@ -439,14 +439,6 @@
439 self.logger.info(439 self.logger.info(
440 "'%s' error updating %s: %s" % (440 "'%s' error updating %s: %s" % (
441 error_type.title, bug_tracker.baseurl, error))441 error_type.title, bug_tracker.baseurl, error))
442 # This is retained to make tests happy. It will be
443 # removed later when the checkwatches OOPS
444 # infrastructure can be.
445 if isinstance(error, UnknownBugTrackerTypeError):
446 message = (
447 "ExternalBugtracker for BugTrackerType '%s' is not "
448 "known." % (error.bugtrackertypename))
449 self.warning(message)
450 else:442 else:
451 for remotesystem, bug_watch_batch in trackers_and_watches:443 for remotesystem, bug_watch_batch in trackers_and_watches:
452 self.updateBugWatches(444 self.updateBugWatches(