Merge lp:~justin-fathomdb/nova/bug607541 into lp:~hudson-openstack/nova/trunk

Proposed by justinsb
Status: Merged
Merged at revision: 193
Proposed branch: lp:~justin-fathomdb/nova/bug607541
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 53 lines (+18/-4)
1 file modified
nova/objectstore/handler.py (+18/-4)
To merge this branch: bzr merge lp:~justin-fathomdb/nova/bug607541
Reviewer Review Type Date Requested Status
Jay Pipes (community) Needs Fixing
Jesse Andrews (community) Approve
Review via email: mp+30357@code.launchpad.net

Description of the change

Fix bug 607541. Exceptions mapped to 404/401 error codes as they were before the twisted rewrite.

To post a comment you must log in.
Revision history for this message
Jesse Andrews (anotherjesse) wrote :

lgtm

we might want the body content to have a human readable message eventually...

review: Approve
Revision history for this message
justinsb (justin-fathomdb) wrote :

Re: Human Readable; I agree, but we should probably try to match S3 if that's what we're emulating here.

e.g. euca-upload-bundle performs this check instead of checking the response code directly:
 except S3ResponseError, s3error:
        s3error_string = '%s' % (s3error)
        if (s3error_string.find("404") >= 0):

I'd imagine other clients might also have written similarly bizarre logic. I'm not sure exactly what S3 does.

Anyway, this patch is really just restoring the behavior that was there before the twisted rewrite.

Long term, I'd hope that we'd determine our own better way of uploading images than the EC2/S3 approach.

Revision history for this message
Todd Willey (xtoddx) wrote :

We typically make TODO(name): comments so that they have a clear owner. If you don't want it, and nobody in IRC wants it, I'd be okay with TODO(unassigned): or somesuch. Not sure how everyone else feels about it though.

Otherwise lgtm

Revision history for this message
Vish Ishaya (vishvananda) wrote :

agreed on the TODO note. Plz make the change and I'll approve for merging

Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi!

Nice work, Justin!

One note, though, is that I don't see a test case included that verifies the bug and the fix. Could you add one to /nova/tests/objectstore_unittest.py?

If you need assistance creating the test case, gimme a holla on IRC.

Cheers!
jay

review: Needs Fixing
lp:~justin-fathomdb/nova/bug607541 updated
153. By justinsb

Nobody wants to take on this twisted cleanup. It works for now, but could be much nicer if twisted has a nice hook-point for exception mapping

Revision history for this message
Soren Hansen (soren) wrote :

> We typically make TODO(name): comments so that they have a clear owner. If
> you don't want it, and nobody in IRC wants it, I'd be okay with
> TODO(unassigned): or somesuch. Not sure how everyone else feels about it
> though.

Any reason not to just use the bug tracker for this?

Revision history for this message
Soren Hansen (soren) wrote :

I'm happy to accept ownership of the twisted cleanup. I've just been caught up at OSCON and traveling and whatnot. Normalcy should be restored starting tomorrow. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/objectstore/handler.py'
2--- nova/objectstore/handler.py 2010-07-20 01:26:19 +0000
3+++ nova/objectstore/handler.py 2010-07-22 18:53:45 +0000
4@@ -116,7 +116,21 @@
5 logging.debug("Authentication Failure: %s" % ex)
6 raise exception.NotAuthorized
7
8-class S3(Resource):
9+class ErrorHandlingResource(Resource):
10+ """Maps exceptions to 404 / 401 codes. Won't work for exceptions thrown after NOT_DONE_YET is returned."""
11+ # TODO(unassigned) (calling-all-twisted-experts): This needs to be plugged in to the right place in twisted...
12+ # This doesn't look like it's the right place (consider exceptions in getChild; or after NOT_DONE_YET is returned
13+ def render(self, request):
14+ try:
15+ return Resource.render(self, request)
16+ except exception.NotFound:
17+ request.setResponseCode(404)
18+ return ''
19+ except exception.NotAuthorized:
20+ request.setResponseCode(403)
21+ return ''
22+
23+class S3(ErrorHandlingResource):
24 """Implementation of an S3-like storage server based on local files."""
25 def getChild(self, name, request):
26 request.context = get_context(request)
27@@ -136,7 +150,7 @@
28 }})
29 return server.NOT_DONE_YET
30
31-class BucketResource(Resource):
32+class BucketResource(ErrorHandlingResource):
33 def __init__(self, name):
34 Resource.__init__(self)
35 self.name = name
36@@ -186,7 +200,7 @@
37 return ''
38
39
40-class ObjectResource(Resource):
41+class ObjectResource(ErrorHandlingResource):
42 def __init__(self, bucket, name):
43 Resource.__init__(self)
44 self.bucket = bucket
45@@ -227,7 +241,7 @@
46 request.setResponseCode(204)
47 return ''
48
49-class ImageResource(Resource):
50+class ImageResource(ErrorHandlingResource):
51 isLeaf = True
52
53 def getChild(self, name, request):