diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-06-01 01:10:47 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-01 01:10:47 +0000 |
| commit | a8113ae0dcc15171d138f6333203d0d16a24c8ea (patch) | |
| tree | 252eed22e8da45fa959ee95866f030c41dca2b28 | |
| parent | 4c0e72a6278d6b21cd00bd695099ad24858c288a (diff) | |
| parent | 81f40ed1ca284bc9a8ee948ae23fdff93d632cb0 (diff) | |
Logs the exception if metadata fails and returns a 500 with an error message to the client.
| -rw-r--r-- | nova/api/ec2/metadatarequesthandler.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nova/api/ec2/metadatarequesthandler.py b/nova/api/ec2/metadatarequesthandler.py index 28f99b0ef..b70266a20 100644 --- a/nova/api/ec2/metadatarequesthandler.py +++ b/nova/api/ec2/metadatarequesthandler.py @@ -23,6 +23,7 @@ import webob.exc from nova import log as logging from nova import flags +from nova import utils from nova import wsgi from nova.api.ec2 import cloud @@ -71,7 +72,15 @@ class MetadataRequestHandler(wsgi.Application): remote_address = req.remote_addr if FLAGS.use_forwarded_for: remote_address = req.headers.get('X-Forwarded-For', remote_address) - meta_data = cc.get_metadata(remote_address) + try: + meta_data = cc.get_metadata(remote_address) + except Exception: + LOG.exception(_('Failed to get metadata for ip: %s'), + remote_address) + msg = _('An unknown error has occurred. ' + 'Please try your request again.') + exc = webob.exc.HTTPInternalServerError(explanation=unicode(msg)) + return exc if meta_data is None: LOG.error(_('Failed to get metadata for ip: %s'), remote_address) raise webob.exc.HTTPNotFound() |
