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
1=== modified file 'lib/lp/bugs/doc/checkwatches-cli-switches.txt'
2--- lib/lp/bugs/doc/checkwatches-cli-switches.txt 2011-02-28 08:59:27 +0000
3+++ lib/lp/bugs/doc/checkwatches-cli-switches.txt 2011-03-16 05:38:26 +0000
4@@ -108,8 +108,6 @@
5 INFO Resetting 5 bug watches for bug tracker 'savannah'
6 INFO Updating 5 watches on bug tracker 'savannah'
7 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
8- WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
9- (OOPS-...)
10 INFO 0 watches left to check on bug tracker 'savannah'
11 INFO Time for this run...
12
13
14=== modified file 'lib/lp/bugs/doc/checkwatches.txt'
15--- lib/lp/bugs/doc/checkwatches.txt 2011-03-10 02:15:00 +0000
16+++ lib/lp/bugs/doc/checkwatches.txt 2011-03-16 05:38:26 +0000
17@@ -14,90 +14,6 @@
18 >>> import transaction
19 >>> transaction.commit()
20
21-We'll add a bug watch to the Gnu Savannah bug tracker so that
22-checkwatches will try to get an ExternalBugTracker with which to update
23-the watch.
24-
25- >>> from canonical.config import config
26- >>> from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
27- >>> from canonical.testing.layers import LaunchpadZopelessLayer
28- >>> from lp.testing.factory import LaunchpadObjectFactory
29-
30- >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
31-
32- >>> factory = LaunchpadObjectFactory()
33- >>> savannah = getUtility(ILaunchpadCelebrities).savannah_tracker
34- >>> bug_watch = factory.makeBugWatch(bugtracker=savannah)
35-
36- >>> transaction.commit()
37- >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
38-
39- >>> import subprocess
40- >>> process = subprocess.Popen(
41- ... ['cronscripts/checkwatches.py', '-v'],
42- ... stdin=subprocess.PIPE, stdout=subprocess.PIPE,
43- ... stderr=subprocess.PIPE)
44- >>> (out, err) = process.communicate()
45- >>> out
46- ''
47- >>> process.returncode
48- 0
49-
50- >>> print err
51- DEBUG ...
52- DEBUG No global batch size specified.
53- DEBUG Skipping updating Ubuntu Bugzilla watches.
54- DEBUG No watches to update on http://bugs.debian.org
55- DEBUG No watches to update on mailto:bugs@example.com
56- DEBUG No watches to update on http://bugzilla.gnome.org/
57- DEBUG No watches to update on http://bugzilla.gnome.org/bugs
58- DEBUG No watches to update on https://bugzilla.mozilla.org/
59- INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
60- WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
61- (OOPS-...)
62- DEBUG No watches to update on http://sourceforge.net/
63- INFO Time for this run: ... seconds.
64- DEBUG Removing lock file:...
65- <BLANKLINE>
66-
67-OOPSes reported by the checkwatches process are raised using the
68-CheckWatchesErrorUtility. The errors have 'CW' in their oops prefix
69-and their type is 'BugWatchUpdateWarning'.
70-
71- >>> from lp.bugs.scripts.checkwatches.base import (
72- ... CheckWatchesErrorUtility)
73- >>> error_utility = CheckWatchesErrorUtility()
74- >>> report = error_utility.getLastOopsReport()
75- >>> report.id
76- 'OOPS-...TCW...'
77- >>> report.type
78- 'BugWatchUpdateWarning'
79-
80- >>> from sys import stdout
81- >>> def dump_last_oops():
82- ... error_utility.getLastOopsReport().write(stdout)
83-
84- >>> dump_last_oops()
85- Oops-Id: OOPS-...TCW...
86- Exception-Type: BugWatchUpdateWarning
87- Exception-Value: ExternalBugtracker for BugTrackerType 'SAVANE' ...
88- Date: ...
89- Page-Id:
90- Branch: ...
91- Revision: ...
92- User: None
93- URL: None
94- Duration: ...
95- Informational: False
96- <BLANKLINE>
97- error-explanation=ExternalBugtracker for ... is not known.
98- ...SELECT BugTracker...
99- ...Transaction completed, status: Active...
100- Traceback (most recent call last):
101- ...
102- BugWatchUpdateWarning: ExternalBugtracker for BugTrackerType 'SAVANE'
103- is not known.
104-
105 We set a default timeout on checkwatches to 30 seconds. In order to test
106 this, we can monkey-patch urllib2.urlopen so that it always raises a
107 timeout and call the checkwatches cronscript machinery directly.
108@@ -105,6 +21,8 @@
109 First, we create some bug watches to test with:
110
111 >>> from datetime import datetime
112+ >>> from canonical.launchpad.interfaces.launchpad import (
113+ ... ILaunchpadCelebrities)
114 >>> from lp.bugs.interfaces.bug import IBugSet
115 >>> from lp.bugs.interfaces.bugtracker import BugTrackerType
116 >>> from lp.bugs.model.bugtracker import BugTracker
117@@ -144,7 +62,10 @@
118 >>> import urllib2
119 >>> urlopen = urllib2.urlopen
120
121- >>> transaction.commit()
122+ >>> from lp.bugs.scripts.checkwatches.base import (
123+ ... CheckWatchesErrorUtility)
124+ >>> error_utility = CheckWatchesErrorUtility()
125+ >>> last_oops_id = error_utility.getLastOopsReport().id
126 >>> def do_not_urlopen(url=None, data=None):
127 ... raise socket.timeout("Connection timed out.")
128 >>> try:
129@@ -154,11 +75,8 @@
130 ... bug_tracker_names=[example_bug_tracker_name])
131 ... finally:
132 ... urllib2.urlopen = urlopen
133- >>> dump_last_oops()
134- Oops-Id: OOPS-...TCW...
135- Exception-Type: BugWatchUpdateWarning
136- Exception-Value: ExternalBugtracker for BugTrackerType 'SAVANE' ...
137- ...
138+ >>> last_oops_id == error_utility.getLastOopsReport().id
139+ True
140
141 Errors that occur when updating a bug watch are recorded against that
142 bug watch. The timeout will be recorded against the bug watch we just
143@@ -196,8 +114,6 @@
144 ... finally:
145 ... externalbugtracker.get_external_bugtracker = (
146 ... real_get_external_bugtracker)
147- WARNING...:ExternalBugtracker for BugTrackerType 'ROUNDUP' is not
148- known. (OOPS-...)
149
150 The bug watch's last error type field will have been updated to reflect
151 the error that was raised:
152@@ -266,9 +182,12 @@
153 called by the checkwatches script, which doesn't know or care about
154 IBugTracker and instances thereof.
155
156-If we look at our Savannah bug tracker, we'll see that it's got one bug
157-watch.
158+Let's first create a watch on our Savannah bug tracker.
159
160+ >>> from lp.testing.dbuser import dbuser
161+ >>> savannah = getUtility(ILaunchpadCelebrities).savannah_tracker
162+ >>> with dbuser('launchpad'):
163+ ... bug_watch = factory.makeBugWatch(bugtracker=savannah)
164 >>> savannah.watches.count()
165 1
166
167@@ -276,8 +195,7 @@
168 that it looks as though it has been updated recently
169
170 >>> login('test@canonical.com')
171- >>> for watch in savannah.watches:
172- ... watch.lastchecked = datetime.now(utc)
173+ >>> savannah.resetWatches()
174
175 So our Savannah instance now has no watches that need checking.
176
177@@ -300,8 +218,6 @@
178 INFO Resetting 1 bug watches for bug tracker 'savannah'
179 INFO Updating 1 watches on bug tracker 'savannah'
180 INFO 'Unsupported Bugtracker' error updating http://savannah.gnu.org/: SAVANE
181- WARNING ExternalBugtracker for BugTrackerType 'SAVANE' is not known.
182- (OOPS-...)
183 INFO 0 watches left to check on bug tracker 'savannah'
184
185 We can see that the Savannah bug watch has been updated recently. Also,
186@@ -316,13 +232,10 @@
187 If a bug tracker doesn't have any watches to update, forceUpdateAll()
188 will ignore it.
189
190- >>> transaction.commit()
191- >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
192- >>> login('test@canonical.com')
193- >>> empty_tracker = factory.makeBugTracker(
194- ... 'http://example.com', BugTrackerType.ROUNDUP)
195- >>> transaction.commit()
196- >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
197+ >>> with dbuser('launchpad'):
198+ ... login('test@canonical.com')
199+ ... empty_tracker = factory.makeBugTracker(
200+ ... 'http://example.com', BugTrackerType.ROUNDUP)
201 >>> empty_tracker_name = empty_tracker.name
202 >>> update_all(empty_tracker_name)
203 INFO Bug tracker 'auto-example.com' doesn't have any watches. Ignoring.
204@@ -336,11 +249,9 @@
205 We'll add some more watches in order to demonstrate this.
206
207 >>> transaction.commit()
208- >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
209- >>> for i in range(5):
210- ... bug_watch = factory.makeBugWatch(bugtracker=empty_tracker)
211- >>> transaction.commit()
212- >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
213+ >>> with dbuser('launchpad'):
214+ ... for i in range(5):
215+ ... bug_watch = factory.makeBugWatch(bugtracker=empty_tracker)
216
217 >>> empty_tracker.watches.count()
218 5
219@@ -443,13 +354,11 @@
220 We'll generate a bug watch with which to test this. The bug watch must
221 be associated with at least one bug task to enable syncing.
222
223- >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
224- >>> login('foo.bar@canonical.com')
225- >>> bug_tracker = factory.makeBugTracker()
226- >>> bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)
227- >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch
228- >>> transaction.commit()
229- >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
230+ >>> with dbuser('launchpad'):
231+ ... login('foo.bar@canonical.com')
232+ ... bug_tracker = factory.makeBugTracker()
233+ ... bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)
234+ ... bug_watch.bug.default_bugtask.bugwatch = bug_watch
235
236 If we pass our UselessExternalBugTracker and the bug watch we just
237 generated to updateBugWatches we can see that its comments will be
238@@ -469,8 +378,7 @@
239 another bug, comments won't be synced and the bug won't be linked back
240 to the remote bug.
241
242- >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
243- >>> bug_15 = getUtility(IBugSet).get(15)
244- >>> bug_watch.bug.markAsDuplicate(bug_15)
245-
246- >>> updater.updateBugWatches(remote_system, [bug_watch], now=nowish)
247+ >>> with dbuser('launchpad'):
248+ ... bug_15 = getUtility(IBugSet).get(15)
249+ ... bug_watch.bug.markAsDuplicate(bug_15)
250+ ... updater.updateBugWatches(remote_system, [bug_watch], now=nowish)
251
252=== modified file 'lib/lp/bugs/scripts/checkwatches/core.py'
253--- lib/lp/bugs/scripts/checkwatches/core.py 2011-03-10 04:17:48 +0000
254+++ lib/lp/bugs/scripts/checkwatches/core.py 2011-03-16 05:38:26 +0000
255@@ -439,14 +439,6 @@
256 self.logger.info(
257 "'%s' error updating %s: %s" % (
258 error_type.title, bug_tracker.baseurl, error))
259- # This is retained to make tests happy. It will be
260- # removed later when the checkwatches OOPS
261- # infrastructure can be.
262- if isinstance(error, UnknownBugTrackerTypeError):
263- message = (
264- "ExternalBugtracker for BugTrackerType '%s' is not "
265- "known." % (error.bugtrackertypename))
266- self.warning(message)
267 else:
268 for remotesystem, bug_watch_batch in trackers_and_watches:
269 self.updateBugWatches(