Fix incorrect reraising of exceptions

There are several places in the code where exception handling raises
the exception variable rather than just calling raise. This results
in the traceback being incorrect.

Had considered adding a hacking check for this, but that becomes a
little tricky. There are valid places where "raise ex" is used that
would prevent a simple check.

Change-Id: Ib2bd745c7ef600c514a94c3fd638d15d17a623a2
This commit is contained in:
Sean McGinnis
2015-04-24 19:15:37 -05:00
parent 7a9afae72d
commit fea27a526c
9 changed files with 19 additions and 19 deletions

View File

@@ -452,7 +452,7 @@ class CommandLineHelper(object):
self.CLI_RESP_PATTERN_LUN_NOT_EXIST) >= 0: self.CLI_RESP_PATTERN_LUN_NOT_EXIST) >= 0:
return False return False
else: else:
raise ex raise
return _lun_state_validation(data) return _lun_state_validation(data)
self._wait_for_a_condition(lun_is_ready, self._wait_for_a_condition(lun_is_ready,
@@ -2428,7 +2428,7 @@ class EMCVnxCliBase(object):
self._client.connect_host_to_storage_group( self._client.connect_host_to_storage_group(
hostname, storage_group) hostname, storage_group)
else: else:
raise ex raise
return hostname return hostname
def get_lun_owner(self, volume): def get_lun_owner(self, volume):
@@ -2629,7 +2629,7 @@ class EMCVnxCliBase(object):
poll=False) poll=False)
except exception.EMCVnxCLICmdError as ex: except exception.EMCVnxCLICmdError as ex:
if ex.kwargs["rc"] != 83: if ex.kwargs["rc"] != 83:
raise ex raise
# Storage Group has not existed yet # Storage Group has not existed yet
self.assure_storage_group(hostname) self.assure_storage_group(hostname)
if self.itor_auto_reg: if self.itor_auto_reg:

View File

@@ -332,7 +332,7 @@ class Client(client_base.Client):
except netapp_api.NaApiError as e: except netapp_api.NaApiError as e:
if e.code != 'UnknownCloneId': if e.code != 'UnknownCloneId':
self._clear_clone(clone_id) self._clear_clone(clone_id)
raise e raise
def _wait_for_clone_finish(self, clone_op_id, vol_uuid): def _wait_for_clone_finish(self, clone_op_id, vol_uuid):
"""Waits till a clone operation is complete or errored out.""" """Waits till a clone operation is complete or errored out."""

View File

@@ -206,13 +206,13 @@ class NetAppNfsDriver(nfs.NfsDriver):
if vol_size != src_vol_size: if vol_size != src_vol_size:
try: try:
self.extend_volume(volume, vol_size) self.extend_volume(volume, vol_size)
except Exception as e: except Exception:
LOG.error( LOG.error(
_LE("Resizing %s failed. Cleaning volume."), _LE("Resizing %s failed. Cleaning volume."),
volume.name) volume.name)
self._execute('rm', path, self._execute('rm', path,
run_as_root=self._execute_as_root) run_as_root=self._execute_as_root)
raise e raise
else: else:
raise exception.CinderException( raise exception.CinderException(
_("NFS file %s not discovered.") % volume['name']) _("NFS file %s not discovered.") % volume['name'])

View File

@@ -154,7 +154,7 @@ class NfsDriver(remotefs.RemoteFSDriver):
msg = _('%s is not installed') % package msg = _('%s is not installed') % package
raise exception.NfsException(msg) raise exception.NfsException(msg)
else: else:
raise exc raise
# Now that all configuration data has been loaded (shares), # Now that all configuration data has been loaded (shares),
# we can "set" our final NAS file security options. # we can "set" our final NAS file security options.

View File

@@ -117,7 +117,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriver):
raise exception.VolumeDriverException( raise exception.VolumeDriverException(
'mount.quobyte is not installed') 'mount.quobyte is not installed')
else: else:
raise exc raise
def set_nas_security_options(self, is_new_cinder_install): def set_nas_security_options(self, is_new_cinder_install):
self.configuration.nas_secure_file_operations = 'true' self.configuration.nas_secure_file_operations = 'true'

View File

@@ -494,10 +494,10 @@ class RBDDriver(driver.RetypeVD, driver.TransferVD, driver.ExtendVD,
LOG.debug("creating snapshot='%s'", clone_snap) LOG.debug("creating snapshot='%s'", clone_snap)
src_volume.create_snap(clone_snap) src_volume.create_snap(clone_snap)
src_volume.protect_snap(clone_snap) src_volume.protect_snap(clone_snap)
except Exception as exc: except Exception:
# Only close if exception since we still need it. # Only close if exception since we still need it.
src_volume.close() src_volume.close()
raise exc raise
# Now clone source volume snapshot # Now clone source volume snapshot
try: try:
@@ -508,10 +508,10 @@ class RBDDriver(driver.RetypeVD, driver.TransferVD, driver.ExtendVD,
self.RBDProxy().clone(client.ioctx, src_name, clone_snap, self.RBDProxy().clone(client.ioctx, src_name, clone_snap,
client.ioctx, dest_name, client.ioctx, dest_name,
features=client.features) features=client.features)
except Exception as exc: except Exception:
src_volume.unprotect_snap(clone_snap) src_volume.unprotect_snap(clone_snap)
src_volume.remove_snap(clone_snap) src_volume.remove_snap(clone_snap)
raise exc raise
finally: finally:
src_volume.close() src_volume.close()

View File

@@ -1259,8 +1259,8 @@ class RemoteFSSnapDriver(RemoteFSDriver):
snapshot['volume_id'], snapshot['volume_id'],
connection_info) connection_info)
LOG.debug('nova call result: %s', result) LOG.debug('nova call result: %s', result)
except Exception as e: except Exception:
LOG.error(_LE('Call to Nova to create snapshot failed %s'), e) LOG.exception(_LE('Call to Nova to create snapshot failed'))
raise raise
# Loop and wait for result # Loop and wait for result
@@ -1344,8 +1344,8 @@ class RemoteFSSnapDriver(RemoteFSDriver):
context, context,
snapshot['id'], snapshot['id'],
delete_info) delete_info)
except Exception as e: except Exception:
LOG.error(_LE('Call to Nova delete snapshot failed %s'), e) LOG.exception(_LE('Call to Nova delete snapshot failed'))
raise raise
# Loop and wait for result # Loop and wait for result

View File

@@ -185,9 +185,9 @@ class RestClientURL(object):
message="REST Not Available: \ message="REST Not Available: \
Please Upgrade") Please Upgrade")
except RestClientError as err: except RestClientError:
del self.headers['authorization'] del self.headers['authorization']
raise err raise
def login(self, auth_str): def login(self, auth_str):
"""Login to an appliance using a user name and password. """Login to an appliance using a user name and password.

View File

@@ -97,7 +97,7 @@ class ZFSSANFSDriver(nfs.NfsDriver):
msg = _('%s is not installed') % package msg = _('%s is not installed') % package
raise exception.NfsException(msg) raise exception.NfsException(msg)
else: else:
raise exc raise
lcfg = self.configuration lcfg = self.configuration
LOG.info(_LI('Connecting to host: %s.'), lcfg.san_ip) LOG.info(_LI('Connecting to host: %s.'), lcfg.san_ip)