Merge lp:~vishvananda/nova/log-metadata-exception into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Brian Waldon
Approved revision: 1090
Merged at revision: 1129
Proposed branch: lp:~vishvananda/nova/log-metadata-exception
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 28 lines (+10/-1)
1 file modified
nova/api/ec2/metadatarequesthandler.py (+10/-1)
To merge this branch: bzr merge lp:~vishvananda/nova/log-metadata-exception
Reviewer Review Type Date Requested Status
Brian Waldon (community) Approve
Devin Carlen (community) Approve
Review via email: mp+61480@code.launchpad.net

Description of the change

Logs the exception if metadata fails and returns a 500 with an error message to the client.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Pretty straightforward, but would you mind rewriting lines 21-26 to return a webob.exc.HTTPInternalServerError response? This would keep in line with the rest of the project returning things like HTTPNotFound rather than a generic webob.Response with status set to 404.

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

> Pretty straightforward, but would you mind rewriting lines 21-26 to return a
> webob.exc.HTTPInternalServerError response? This would keep in line with the
> rest of the project returning things like HTTPNotFound rather than a generic
> webob.Response with status set to 404.

done

1089. By Vish Ishaya

switch to using webob exception

Revision history for this message
Brian Waldon (bcwaldon) wrote :

One last pep8 violation, then you're in.

review: Needs Fixing
1090. By Vish Ishaya

pep8

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

Fixed
On May 31, 2011, at 3:01 PM, Brian Waldon wrote:

> Review: Needs Fixing
> One last pep8 violation, then you're in.
> --
> https://code.launchpad.net/~vishvananda/nova/log-metadata-exception/+merge/61480
> You are the owner of lp:~vishvananda/nova/log-metadata-exception.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Excellent.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/ec2/metadatarequesthandler.py'
2--- nova/api/ec2/metadatarequesthandler.py 2011-03-03 16:04:33 +0000
3+++ nova/api/ec2/metadatarequesthandler.py 2011-05-31 22:52:26 +0000
4@@ -23,6 +23,7 @@
5
6 from nova import log as logging
7 from nova import flags
8+from nova import utils
9 from nova import wsgi
10 from nova.api.ec2 import cloud
11
12@@ -71,7 +72,15 @@
13 remote_address = req.remote_addr
14 if FLAGS.use_forwarded_for:
15 remote_address = req.headers.get('X-Forwarded-For', remote_address)
16- meta_data = cc.get_metadata(remote_address)
17+ try:
18+ meta_data = cc.get_metadata(remote_address)
19+ except Exception:
20+ LOG.exception(_('Failed to get metadata for ip: %s'),
21+ remote_address)
22+ msg = _('An unknown error has occurred. '
23+ 'Please try your request again.')
24+ exc = webob.exc.HTTPInternalServerError(explanation=unicode(msg))
25+ return exc
26 if meta_data is None:
27 LOG.error(_('Failed to get metadata for ip: %s'), remote_address)
28 raise webob.exc.HTTPNotFound()