Merge lp:~jcsackett/launchpad/redirects-681034 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | j.c.sackett |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12051 |
Proposed branch: | lp:~jcsackett/launchpad/redirects-681034 |
Merge into: | lp:launchpad |
Diff against target: |
102 lines (+30/-9) 2 files modified
lib/lp/registry/scripts/distributionmirror_prober.py (+19/-3) lib/lp/registry/tests/test_distributionmirror_prober.py (+11/-6) |
To merge this branch: | bzr merge lp:~jcsackett/launchpad/redirects-681034 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Henning Eggers (community) | code | Approve | |
Review via email: mp+43392@code.launchpad.net |
Commit message
[r=henninge]
Description of the change
Summary
=======
Redirects in the distribution mirror prober can take go to urls that aren't supported. While the entry of url that is unsupported as the initial prober target should be treated as an OOPS, there's nothing launchpad can do about a redirection set by another machine. At best we can log the error and move on, using the existing methods for dealing with url issues and expected errors.
Pre Implementation
==================
Spoke with Curtis Hovey regarding the source of the problem. Spoke with Guilherme Salgado regarding handling of errors and suppressing the OOPS in the prober.
Proposed Fix
============
Rather than simply raising the error, we need to log the error and then escape from the redirect method safely.
Implementation
==============
MirrorCallbacks already have a set of expected errors; this branch creates a new exception descended from UnknownURLScheme called UnknownURLSchem
In the redirect method, if an UnknownURLScheme is raised, UnknownURLSchem
Tests
=====
bin/test -m lp.registry.
Lint
====
make lint output:
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
./lib/lp/
143: E301 expected 1 blank line, found 0
149: E301 expected 1 blank line, found 0
180: E301 expected 1 blank line, found 0
201: E301 expected 1 blank line, found 0
211: E301 expected 1 blank line, found 0
219: E301 expected 1 blank line, found 0
236: E301 expected 1 blank line, found 2
309: E301 expected 1 blank line, found 0
400: E301 expected 1 blank line, found 0
411: E301 expected 1 blank line, found 0
529: E301 expected 1 blank line, found 0
537: E301 expected 1 blank line, found 0
609: E301 expected 1 blank line, found 0
731: E301 expected 1 blank line, found 0
736: E301 expected 1 blank line, found 0
All E301s are nested functions.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello Jonathan,
thank you for this improvement. The code looks good, I just have a little
suggestion and a question.
review approve code
Cheers,
Henning
Am 10.12.2010 22:18, schrieb j.c.sackett: registry/ scripts/ distributionmir ror_prober. py' registry/ scripts/ distributionmir ror_prober. py 2010-08-20 20:31:18 +0000 registry/ scripts/ distributionmir ror_prober. py 2010-12-10 21:18:14 +0000
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
[...]
> @@ -540,7 +552,12 @@ oberCallbacks( LoggingMixin) : eAfterRedirect,
>
> class MirrorCDImagePr
>
> - expected_failures = (BadResponseCode, ProberTimeout, ConnectionSkipped)
> + expected_failures = (
> + BadResponseCode,
> + ProberTimeout,
> + ConnectionSkipped,
> + UnknownURLSchem
> + )
Thanks for doing the reformatting. AFAICT the order of the content of
expected_failures is irrelevant, so you could as well order them
alphabetically, like imports.
> registry/ tests/test_ distributionmir ror_prober. py' registry/ tests/test_ distributionmir ror_prober. py 2010-11-22 13:55:32 +0000 registry/ tests/test_ distributionmir ror_prober. py 2010-12-10 21:18:14 +0000
> def __init__(self, mirror, distroseries, flavour, log_file):
> self.mirror = mirror
> @@ -735,4 +752,3 @@
> assert port.isdigit()
> port = int(port)
> return scheme, host, port, path
> -
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
[...]
> @@ -651,10 +650,16 @@ Equal( callbacks. expected_ failures) , eCode, ProberTimeout, ConnectionSkipp ed])) eAfterRedirect,
> # some times.
> self.failUnless
> set(self.
> - set([BadRespons
> + set([
> + BadResponseCode,
> + ProberTimeout,
> + ConnectionSkipped,
> + UnknownURLSchem
> + ]))
I realize that this is twsited-related code, so there may be a reason why se(WithFactory) is not use. With it, you could use cool stuff qual" and could do without the "set" trick. So you know a
LaunchpadTestCa
like "assertContentE
reason that this test uses unittest.TestCase?
> exceptions = [BadResponseCod e(str(httplib. NOT_FOUND) ), localhost/ ', 5), ed()] ed(), eAfterRedirect( 'https:/ /localhost')] ensureOrDeleteM irrorCDImageSer ies( exception) )])
> ProberTimeout('http://
> - ConnectionSkipp
> + ConnectionSkipp
> + UnknownURLSchem
> for exception in exceptions:
> failure = self.callbacks.
> [(defer.FAILURE, Failure(
-----BEGIN PGP SIGNATURE----- enigmail. mozdev. org/
GON0ACgkQBT3oW1 L17ijBWACgiEnQu 82vvgPQQRqY56er jlpg kHn54TeYcRy49pZ dh
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAk0
QY4An3xYVbKokM0
=egAt
-----END PGP SIGNATURE-----