Merge lp:~pfalcon/linaro-android-mirror/xmlrpc-error-msg into lp:linaro-android-mirror

Proposed by Paul Sokolovsky
Status: Merged
Approved by: Paul Sokolovsky
Approved revision: 44
Merged at revision: 43
Proposed branch: lp:~pfalcon/linaro-android-mirror/xmlrpc-error-msg
Merge into: lp:linaro-android-mirror
Diff against target: 81 lines (+48/-1)
4 files modified
linaro_android_mirror/service.py (+17/-1)
linaro_android_mirror/tests/data/manifest-bad-loc.xml (+5/-0)
linaro_android_mirror/tests/data/manifest-no-rev.xml (+5/-0)
linaro_android_mirror/tests/test_mirrorer_integrational.py (+21/-0)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-mirror/xmlrpc-error-msg
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Pending
Review via email: mp+61739@code.launchpad.net

Description of the change

Hello Michael,

Here's patch to actually report any exception happened during mirroring down to client, because so far client receive generic error, e.g. https://android-build.linaro.org/jenkins/job/linaro-android_leb-panda/36/console

It also shows kind of issues I have with Twisted - it has strange defaults (not passing error content down to client), and to work that around, one have to dig in internal classes. Or maybe chain error callback thru the web of code, but that's exactly why exceptions were invented - to avoid that. Anyway, I based this solution on discussion at and around http://twistedmatrix.com/pipermail/twisted-python/2005-April/010248.html . Please see if this is good enough or is there other way to do it.

Thanks,
Paul

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I think the approach in lp:~mwhudson/linaro-android-mirror/xmlrpc-error-msg is a bit cleaner. I agree that DeferredList and XMLRPC error reporting are both pretty awkward though.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

> I think the approach in lp:~mwhudson/linaro-android-mirror/xmlrpc-error-msg is
> a bit cleaner. I agree that DeferredList and XMLRPC error reporting are both
> pretty awkward though.

So, should that implementation be used instead of mine, because it seems to be applied on top? Also, from my, non-twisted-expert view, it has the same traits (uses a private method, fishes for stuff like failure.value.subFailure), but also adds more: deeper black twisted magic, overloads semantics of standard method. All in all, Michael, if that's the right way to do it, can you please merge it the way it should be (instead or on top of my changes). Thanks!

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Ok, we're having issues due to this in realtime (developers can't get build up due to mirror errors, and cannot see the actual errors, and need to recurse to me for looking them up). So, I'll merge this patch as knowing working, let's elaborate it as needed afterwards.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro_android_mirror/service.py'
--- linaro_android_mirror/service.py 2011-04-18 13:02:12 +0000
+++ linaro_android_mirror/service.py 2011-05-20 10:57:35 +0000
@@ -1,14 +1,30 @@
1import time1import time
2from xmlrpclib import Fault
23
3from twisted.web.xmlrpc import XMLRPC4from twisted.web.xmlrpc import XMLRPC
4from twisted.python import log5from twisted.python import log
6from twisted.internet.defer import FirstError
57
6from linaro_android_mirror.mirrorer import mirror8from linaro_android_mirror.mirrorer import mirror
7from linaro_android_mirror.factor_manifest import make_slave_manifest9from linaro_android_mirror.factor_manifest import make_slave_manifest
8from . import settings10from . import settings
911
1012
11class MirrorEndpoint(XMLRPC):13class ExceptionPropogatingXMLRPC(XMLRPC):
14 "XMLRPC subclass which returns error message to the client."
15
16 # See http://twistedmatrix.com/pipermail/twisted-python/2005-April/010248.html
17 def _ebRender(self, failure):
18 if isinstance(failure.value, Fault):
19 return failure.value
20 # Unwrap original exception which was thrown
21 exc = failure.value
22 if isinstance(exc, FirstError):
23 exc = exc.subFailure.value
24 return Fault(self.FAILURE, str(exc))
25
26
27class MirrorEndpoint(ExceptionPropogatingXMLRPC):
1228
13 def xmlrpc_mirror(self, text):29 def xmlrpc_mirror(self, text):
14 log.msg("mirror request: in %d bytes" % len(text))30 log.msg("mirror request: in %d bytes" % len(text))
1531
=== added file 'linaro_android_mirror/tests/data/manifest-bad-loc.xml'
--- linaro_android_mirror/tests/data/manifest-bad-loc.xml 1970-01-01 00:00:00 +0000
+++ linaro_android_mirror/tests/data/manifest-bad-loc.xml 2011-05-20 10:57:35 +0000
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<manifest>
3 <remote fetch="git://git.linaro.org/" name="linaro"/>
4 <project name="theres/no/such/location" path="hardware/libhardware" remote="linaro" revision="master" />
5</manifest>
06
=== added file 'linaro_android_mirror/tests/data/manifest-no-rev.xml'
--- linaro_android_mirror/tests/data/manifest-no-rev.xml 1970-01-01 00:00:00 +0000
+++ linaro_android_mirror/tests/data/manifest-no-rev.xml 2011-05-20 10:57:35 +0000
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<manifest>
3 <remote fetch="git://git.linaro.org/" name="linaro"/>
4 <project name="theres/no/such/location" path="hardware/libhardware" remote="linaro"/>
5</manifest>
06
=== added file 'linaro_android_mirror/tests/test_mirrorer_integrational.py'
--- linaro_android_mirror/tests/test_mirrorer_integrational.py 1970-01-01 00:00:00 +0000
+++ linaro_android_mirror/tests/test_mirrorer_integrational.py 2011-05-20 10:57:35 +0000
@@ -0,0 +1,21 @@
1import os
2import sys
3import xmlrpclib
4
5# Integrational test for mirror service, expects server to be running at localhost
6
7def _test_for_fault(manifest_file, error_substr):
8 service = xmlrpclib.ServerProxy("http://localhost:8080")
9 basedir = os.path.dirname(__file__)
10 manifest = open(os.path.join(basedir, manifest_file)).read()
11 try:
12 service.mirror(manifest)
13 assert False, "Expected exception was not raised"
14 except xmlrpclib.Fault, e:
15 assert error_substr in e.faultString
16
17def test_bad_manifest_git_loc():
18 _test_for_fault("data/manifest-bad-loc.xml", "Cannot fetch theres/no/such/location")
19
20def test_bad_manifest():
21 _test_for_fault("data/manifest-no-rev.xml", "no revision for project theres/no/such/location")

Subscribers

People subscribed via source and target branches