Merge "Save model_update as admin in create_volume"
This commit is contained in:
commit
559d63f7d4
@ -1054,6 +1054,14 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
|||||||
self.volume.create_volume(self.context, volume)
|
self.volume.create_volume(self.context, volume)
|
||||||
self.assertEqual(fake.PROVIDER_ID, volume['provider_id'])
|
self.assertEqual(fake.PROVIDER_ID, volume['provider_id'])
|
||||||
|
|
||||||
|
def test_create_volume_with_admin_metadata(self):
|
||||||
|
with mock.patch.object(
|
||||||
|
self.volume.driver, 'create_volume',
|
||||||
|
return_value={'admin_metadata': {'foo': 'bar'}}):
|
||||||
|
volume = tests_utils.create_volume(self.user_context)
|
||||||
|
self.volume.create_volume(self.user_context, volume)
|
||||||
|
self.assertEqual({'foo': 'bar'}, volume['admin_metadata'])
|
||||||
|
|
||||||
@mock.patch.object(key_manager, 'API', new=fake_keymgr.fake_api)
|
@mock.patch.object(key_manager, 'API', new=fake_keymgr.fake_api)
|
||||||
def test_create_delete_volume_with_encrypted_volume_type(self):
|
def test_create_delete_volume_with_encrypted_volume_type(self):
|
||||||
cipher = 'aes-xts-plain64'
|
cipher = 'aes-xts-plain64'
|
||||||
|
@ -857,8 +857,9 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask):
|
|||||||
# Persist any model information provided on creation.
|
# Persist any model information provided on creation.
|
||||||
try:
|
try:
|
||||||
if model_update:
|
if model_update:
|
||||||
volume.update(model_update)
|
with volume.obj_as_admin():
|
||||||
volume.save()
|
volume.update(model_update)
|
||||||
|
volume.save()
|
||||||
except exception.CinderException:
|
except exception.CinderException:
|
||||||
# If somehow the update failed we want to ensure that the
|
# If somehow the update failed we want to ensure that the
|
||||||
# failure is logged (but not try rescheduling since the volume at
|
# failure is logged (but not try rescheduling since the volume at
|
||||||
|
Loading…
Reference in New Issue
Block a user