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
1=== modified file 'linaro_android_mirror/service.py'
2--- linaro_android_mirror/service.py 2011-04-18 13:02:12 +0000
3+++ linaro_android_mirror/service.py 2011-05-20 10:57:35 +0000
4@@ -1,14 +1,30 @@
5 import time
6+from xmlrpclib import Fault
7
8 from twisted.web.xmlrpc import XMLRPC
9 from twisted.python import log
10+from twisted.internet.defer import FirstError
11
12 from linaro_android_mirror.mirrorer import mirror
13 from linaro_android_mirror.factor_manifest import make_slave_manifest
14 from . import settings
15
16
17-class MirrorEndpoint(XMLRPC):
18+class ExceptionPropogatingXMLRPC(XMLRPC):
19+ "XMLRPC subclass which returns error message to the client."
20+
21+ # See http://twistedmatrix.com/pipermail/twisted-python/2005-April/010248.html
22+ def _ebRender(self, failure):
23+ if isinstance(failure.value, Fault):
24+ return failure.value
25+ # Unwrap original exception which was thrown
26+ exc = failure.value
27+ if isinstance(exc, FirstError):
28+ exc = exc.subFailure.value
29+ return Fault(self.FAILURE, str(exc))
30+
31+
32+class MirrorEndpoint(ExceptionPropogatingXMLRPC):
33
34 def xmlrpc_mirror(self, text):
35 log.msg("mirror request: in %d bytes" % len(text))
36
37=== added file 'linaro_android_mirror/tests/data/manifest-bad-loc.xml'
38--- linaro_android_mirror/tests/data/manifest-bad-loc.xml 1970-01-01 00:00:00 +0000
39+++ linaro_android_mirror/tests/data/manifest-bad-loc.xml 2011-05-20 10:57:35 +0000
40@@ -0,0 +1,5 @@
41+<?xml version="1.0" encoding="UTF-8"?>
42+<manifest>
43+ <remote fetch="git://git.linaro.org/" name="linaro"/>
44+ <project name="theres/no/such/location" path="hardware/libhardware" remote="linaro" revision="master" />
45+</manifest>
46
47=== added file 'linaro_android_mirror/tests/data/manifest-no-rev.xml'
48--- linaro_android_mirror/tests/data/manifest-no-rev.xml 1970-01-01 00:00:00 +0000
49+++ linaro_android_mirror/tests/data/manifest-no-rev.xml 2011-05-20 10:57:35 +0000
50@@ -0,0 +1,5 @@
51+<?xml version="1.0" encoding="UTF-8"?>
52+<manifest>
53+ <remote fetch="git://git.linaro.org/" name="linaro"/>
54+ <project name="theres/no/such/location" path="hardware/libhardware" remote="linaro"/>
55+</manifest>
56
57=== added file 'linaro_android_mirror/tests/test_mirrorer_integrational.py'
58--- linaro_android_mirror/tests/test_mirrorer_integrational.py 1970-01-01 00:00:00 +0000
59+++ linaro_android_mirror/tests/test_mirrorer_integrational.py 2011-05-20 10:57:35 +0000
60@@ -0,0 +1,21 @@
61+import os
62+import sys
63+import xmlrpclib
64+
65+# Integrational test for mirror service, expects server to be running at localhost
66+
67+def _test_for_fault(manifest_file, error_substr):
68+ service = xmlrpclib.ServerProxy("http://localhost:8080")
69+ basedir = os.path.dirname(__file__)
70+ manifest = open(os.path.join(basedir, manifest_file)).read()
71+ try:
72+ service.mirror(manifest)
73+ assert False, "Expected exception was not raised"
74+ except xmlrpclib.Fault, e:
75+ assert error_substr in e.faultString
76+
77+def test_bad_manifest_git_loc():
78+ _test_for_fault("data/manifest-bad-loc.xml", "Cannot fetch theres/no/such/location")
79+
80+def test_bad_manifest():
81+ _test_for_fault("data/manifest-no-rev.xml", "no revision for project theres/no/such/location")

Subscribers

People subscribed via source and target branches