[openstack-dev] [cinder][oslo] Serialising exceptions

git harry git-harry at live.co.uk
Mon Apr 14 17:08:41 UTC 2014


A bug has been submitted, https://bugs.launchpad.net/cinder/+bug/1301249, which shows a failure when oslo.messaging tries to serialise an exception with jsonutils - a ValueError is raised. I've had a search through the code and I'm pretty sure there are around 50+ cases where this will happen:

cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/backup/drivers/swift.py raise exception.SwiftConnectionFailed(reason=err)
cinder/volume/driver.py raise exception.ExportFailure(reason=ex)
cinder/volume/drivers/coraid.py raise exception.CoraidESMNotAvailable(reason=e)
cinder/volume/drivers/netapp/api.py raise NaApiError('Unexpected error', e)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.InvalidInput(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_3par_common.py raise exception.CinderException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py raise exception.SnapshotIsBusy(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.DriverNotInitialized(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.SnapshotIsBusy(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py raise exception.VolumeBackendAPIException(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/san/hp/hp_msa_common.py raise exception.Invalid(ex)
cinder/volume/drivers/vmware/vim.py raise error_util.VimFaultException(fault_list, excep)
cinder/volume/flows/manager/create_volume.py raise exception.MetadataCopyFailure(reason=ex)
cinder/volume/flows/manager/create_volume.py raise exception.MetadataUpdateFailure(reason=ex)
cinder/volume/flows/manager/create_volume.py raise exception.MetadataUpdateFailure(reason=ex)
cinder/volume/flows/manager/create_volume.py raise exception.ImageUnacceptable(ex)

There seem to me to be three ways to fix this:
1. throw six.text_type round all the arguments that are exceptions - although this doesn't stop the same thing happening again
2. modify CinderException so that if message is an exception or, args or kwarg contains one it get converted to a string
3. modify jsonutils.py in oslo-incubator to automatically convert exceptions to strings.

Does anyone have any thoughts on this? I lean towards trying to get an additional test in to_primitive in jsonutils to convert exceptions but I don't know if there is a reason why that isn't already done.

Thanks,
git-harry 		 	   		  


More information about the OpenStack-dev mailing list