From 3801a4d2f4c59dbfda49131ddde22fcb3976d651 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 21 Mar 2013 18:48:30 -0400 Subject: 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 --- nova/volume/cinder.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'nova') diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index e465daf1c..ca7f86da1 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']) -- cgit