summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sdague@linux.vnet.ibm.com>2013-03-21 18:48:30 -0400
committerVishvananda Ishaya <vishvananda@gmail.com>2013-03-26 14:41:17 -0700
commit9bfad01d9082992d10ece85d141c5c5760f5b935 (patch)
tree22be34354cf488c5465d735cdf74c580e0342b3e
parentddff7707be535bd082f291bb38b31406f338cefe (diff)
downloadnova-9bfad01d9082992d10ece85d141c5c5760f5b935.tar.gz
translate cinder BadRequest exception
if we attempt to create a volume with values that are invalid (like a non numeric value for size) we properly get a BadRequest returned from cinder. However we inproperly pass that cinderclient exception all the way to the top of the request process, causing a stack trace to appear in the logs because this is an exception type Nova doesn't understand. This situation is triggered by Tempest on every run, and while the return is successful, the stack trace might spook people. Fix this by increasing the scope of the existing _reraise_translated_volume_exception() method. Longer term it would make sense to have a decorator that handles all possible exceptions we'd expect from cinder client and turn them into Nova exceptions. This reduces the number of stack traces in nova-api by 6 on a successful Tempest run. Fixes bug #1158505 Step towards blueprint no-stacktraces-in-logs Change-Id: Ifcfbd5eb11fe9f038f648ca5291499290b7126b1 (cherry picked from commit 3801a4d2f4c59dbfda49131ddde22fcb3976d651)
-rw-r--r--nova/volume/cinder.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index e465daf1c3..ca7f86da1c 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -171,7 +171,7 @@ def _untranslate_snapshot_summary_view(context, snapshot):
class API(base.Base):
"""API for interacting with the volume manager."""
- def _reraise_translated_volume_exception(self, volume_id):
+ def _reraise_translated_volume_exception(self, volume_id=None):
"""Transform the exception for the volume but keep its traceback
intact."""
exc_type, exc_value, exc_trace = sys.exc_info()
@@ -181,6 +181,8 @@ class API(base.Base):
def _translate_volume_exception(self, volume_id, exc_value):
if isinstance(exc_value, cinder_exception.NotFound):
return exception.VolumeNotFound(volume_id=volume_id)
+ elif isinstance(exc_value, cinder_exception.BadRequest):
+ return exception.InvalidInput(reason=exc_value.message)
return exc_value
def get(self, context, volume_id):
@@ -265,9 +267,11 @@ class API(base.Base):
metadata=metadata,
imageRef=image_id)
- item = cinderclient(context).volumes.create(size, **kwargs)
-
- return _untranslate_volume_summary_view(context, item)
+ try:
+ item = cinderclient(context).volumes.create(size, **kwargs)
+ return _untranslate_volume_summary_view(context, item)
+ except Exception:
+ self._reraise_translated_volume_exception()
def delete(self, context, volume):
cinderclient(context).volumes.delete(volume['id'])