Merge lp:~wgrant/launchpad/silence-of-the-prober-ii into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 12408
Proposed branch: lp:~wgrant/launchpad/silence-of-the-prober-ii
Merge into: lp:launchpad
Diff against target: 98 lines (+27/-2)
4 files modified
lib/lp/registry/model/distributionmirror.py (+2/-1)
lib/lp/registry/scripts/distributionmirror_prober.py (+2/-1)
lib/lp/registry/tests/test_distributionmirror.py (+20/-0)
lib/lp/registry/tests/test_distributionmirror_prober.py (+3/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/silence-of-the-prober-ii
Reviewer Review Type Date Requested Status
Tim Penhey (community) code Approve
Steve Kowalik (community) code* Approve
Review via email: mp+50273@code.launchpad.net

Commit message

[r=stevenk,thumper][bug=370329,502842,721028] Fix a few errors in the distribution mirror prober.

Description of the change

This branch fixes three issues in the mirror prober that make my inbox sad:

 - Sending a failure email for a mirror with a deactivated owner causes an exception due to a lack of To addresses. I've fixed this by first checking if the set of destination addresses is non-empty.
 - Some mirrors are too cool for 404s, instead redirecting to a special Not Found document. The prober logged these incidents as errors that required investigation. I've added them as an expected error alongside other invalid redirects and response codes, so they behave correctly like 404s.
 - Some non-Ubuntu mirrors exist, but we do not support probing them. This is a routine situation, not requiring any special attention. I have reduced its warning from INFO to DEBUG due to its unimportance.

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

This change looks great to me, and awesome work fixing 3 critical bugs.

review: Approve (code*)
Revision history for this message
Tim Penhey (thumper) :
review: Approve (code)
Revision history for this message
Curtis Hovey (sinzui) wrote :

I am very excited to see these issues fixed. Thanks William.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/distributionmirror.py'
2--- lib/lp/registry/model/distributionmirror.py 2011-01-20 20:27:43 +0000
3+++ lib/lp/registry/model/distributionmirror.py 2011-02-18 05:04:57 +0000
4@@ -387,7 +387,8 @@
5
6 if notify_owner:
7 owner_address = get_contact_email_addresses(self.owner)
8- simple_sendmail(fromaddress, owner_address, subject, message)
9+ if len(owner_address) > 0:
10+ simple_sendmail(fromaddress, owner_address, subject, message)
11
12 def newProbeRecord(self, log_file):
13 """See IDistributionMirror"""
14
15=== modified file 'lib/lp/registry/scripts/distributionmirror_prober.py'
16--- lib/lp/registry/scripts/distributionmirror_prober.py 2010-12-24 17:08:10 +0000
17+++ lib/lp/registry/scripts/distributionmirror_prober.py 2011-02-18 05:04:57 +0000
18@@ -565,6 +565,7 @@
19 BadResponseCode,
20 ConnectionSkipped,
21 ProberTimeout,
22+ RedirectToDifferentFile,
23 UnknownURLSchemeAfterRedirect,
24 )
25
26@@ -848,7 +849,7 @@
27 # Some people registered mirrors on distros other than Ubuntu back
28 # in the old times, so now we need to do this small hack here.
29 if not mirror.distribution.full_functionality:
30- self.logger.info(
31+ self.logger.debug(
32 "Mirror '%s' of distribution '%s' can't be probed --we "
33 "only probe Ubuntu mirrors."
34 % (mirror.name, mirror.distribution.name))
35
36=== modified file 'lib/lp/registry/tests/test_distributionmirror.py'
37--- lib/lp/registry/tests/test_distributionmirror.py 2011-01-20 17:54:24 +0000
38+++ lib/lp/registry/tests/test_distributionmirror.py 2011-02-18 05:04:57 +0000
39@@ -23,6 +23,7 @@
40 from lp.registry.model.distributionmirror import DistributionMirror
41 from lp.services.mail import stub
42 from lp.services.worlddata.interfaces.country import ICountrySet
43+from lp.testing import login_as
44 from lp.testing.factory import LaunchpadObjectFactory
45
46
47@@ -208,6 +209,25 @@
48 self.failUnlessEqual(len(stub.test_emails), 0)
49 stub.test_emails = []
50
51+ def test_no_email_sent_to_uncontactable_owner(self):
52+ # If the owner has no contact address, only the mirror admins are
53+ # notified.
54+ mirror = self.cdimage_mirror
55+ login_as(mirror.owner)
56+ # Deactivate the mirror owner to remove the contact address.
57+ mirror.owner.deactivateAccount("I hate mirror spam.")
58+ login_as(mirror.distribution.mirror_admin)
59+ # Clear out notifications about the new team member.
60+ transaction.commit()
61+ stub.test_emails = []
62+
63+ # Disabling the mirror results in a single notification to the
64+ # mirror admins.
65+ self.factory.makeMirrorProbeRecord(mirror)
66+ mirror.disable(notify_owner=True, log="It broke.")
67+ transaction.commit()
68+ self.failUnlessEqual(len(stub.test_emails), 1)
69+
70
71 class TestDistributionMirrorSet(unittest.TestCase):
72 layer = LaunchpadFunctionalLayer
73
74=== modified file 'lib/lp/registry/tests/test_distributionmirror_prober.py'
75--- lib/lp/registry/tests/test_distributionmirror_prober.py 2010-12-24 10:03:15 +0000
76+++ lib/lp/registry/tests/test_distributionmirror_prober.py 2011-02-18 05:04:57 +0000
77@@ -57,6 +57,7 @@
78 RedirectAwareProberFactory,
79 RedirectAwareProberProtocol,
80 RequestManager,
81+ RedirectToDifferentFile,
82 restore_http_proxy,
83 should_skip_host,
84 UnknownURLSchemeAfterRedirect,
85@@ -666,11 +667,13 @@
86 BadResponseCode,
87 ProberTimeout,
88 ConnectionSkipped,
89+ RedirectToDifferentFile,
90 UnknownURLSchemeAfterRedirect,
91 ]))
92 exceptions = [BadResponseCode(str(httplib.NOT_FOUND)),
93 ProberTimeout('http://localhost/', 5),
94 ConnectionSkipped(),
95+ RedirectToDifferentFile('/foo', '/bar'),
96 UnknownURLSchemeAfterRedirect('https://localhost')]
97 for exception in exceptions:
98 failure = callbacks.ensureOrDeleteMirrorCDImageSeries(