diff options
| author | Sean Dague <sdague@linux.vnet.ibm.com> | 2013-03-21 18:48:30 -0400 |
|---|---|---|
| committer | Sean Dague <sdague@linux.vnet.ibm.com> | 2013-03-22 10:23:07 -0400 |
| commit | 3801a4d2f4c59dbfda49131ddde22fcb3976d651 (patch) | |
| tree | 267d275e373a4c757dab8bfafb00ab8e3beebd27 | |
| parent | 5499640f639009f60fbf909786770654e1f1b5a0 (diff) | |
| download | nova-3801a4d2f4c59dbfda49131ddde22fcb3976d651.tar.gz nova-3801a4d2f4c59dbfda49131ddde22fcb3976d651.tar.xz nova-3801a4d2f4c59dbfda49131ddde22fcb3976d651.zip | |
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
| -rw-r--r-- | nova/volume/cinder.py | 12 |
1 files changed, 8 insertions, 4 deletions
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']) |
