If there is a problem removing the encryption key from the key manager
(e.g. because the key has been manually deleted already) then the
volume delete should not fail - this leaves undeletable volumes.
Just log a warning and continue instead.
Closes-bug:
1552169
Change-Id: Id3571cbfa7c66787573cf750735be33a440d15dc
volume['id'])
self.assertIsNone(entry)
+ def test_delete_volume_with_keymanager_exception(self):
+ volume_params = {
+ 'host': 'some_host',
+ 'size': 1
+ }
+ volume_api = cinder.volume.api.API()
+ volume = tests_utils.create_volume(self.context, **volume_params)
+
+ with mock.patch.object(
+ volume_api.key_manager, 'delete_key') as key_del_mock:
+ key_del_mock.side_effect = Exception("Key not found")
+ volume_api.delete(self.context, volume)
+
@ddt.ddt
class DiscardFlagTestCase(BaseVolumeTestCase):
try:
self.key_manager.delete_key(context, encryption_key_id)
except Exception as e:
- msg = _("Unable to delete encrypted volume: %s.") % e.msg
- raise exception.InvalidVolume(reason=msg)
+ LOG.warning(_LW("Unable to delete encryption key for "
+ "volume: %s."), e.msg, resource=volume)
self.volume_rpcapi.delete_volume(context,
volume,