Merge "Handle external events in extend volume"
This commit is contained in:
commit
3cdf861bef
@ -2838,7 +2838,8 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
||||
detail=message_field.Detail.DRIVER_FAILED_EXTEND)
|
||||
|
||||
@mock.patch('cinder.compute.API')
|
||||
def _test_extend_volume_manager_successful(self, volume, nova_api):
|
||||
def _test_extend_volume_manager_successful(self, volume, nova_api,
|
||||
attached_to_glance=False):
|
||||
"""Test volume can be extended at the manager level."""
|
||||
def fake_extend(volume, new_size):
|
||||
volume['size'] = new_size
|
||||
@ -2866,8 +2867,11 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
||||
instance_uuids = [
|
||||
attachment.instance_uuid
|
||||
for attachment in volume.volume_attachment]
|
||||
nova_extend_volume.assert_called_with(
|
||||
self.context, instance_uuids, volume.id)
|
||||
if attached_to_glance:
|
||||
nova_extend_volume.assert_not_called()
|
||||
else:
|
||||
nova_extend_volume.assert_called_with(
|
||||
self.context, instance_uuids, volume.id)
|
||||
|
||||
def test_extend_volume_manager_available_fails_with_exception(self):
|
||||
volume = tests_utils.create_volume(self.context, size=2,
|
||||
@ -2913,6 +2917,22 @@ class VolumeTestCase(base.BaseVolumeTestCase):
|
||||
self.volume.detach_volume(self.context, volume.id, attachment.id)
|
||||
self.volume.delete_volume(self.context, volume)
|
||||
|
||||
def test_extend_volume_manager_in_use_glance_store(self):
|
||||
volume = tests_utils.create_volume(self.context, size=2,
|
||||
status='creating', host=CONF.host)
|
||||
self.volume.create_volume(self.context, volume)
|
||||
instance_uuid = None
|
||||
attachment = db.volume_attach(self.context,
|
||||
{'volume_id': volume.id,
|
||||
'attached_host': 'fake-host'})
|
||||
db.volume_attached(self.context, attachment.id, instance_uuid,
|
||||
'fake-host', 'vdb')
|
||||
volume.refresh()
|
||||
self._test_extend_volume_manager_successful(volume,
|
||||
attached_to_glance=True)
|
||||
self.volume.detach_volume(self.context, volume.id, attachment.id)
|
||||
self.volume.delete_volume(self.context, volume)
|
||||
|
||||
@mock.patch('cinder.volume.rpcapi.VolumeAPI.extend_volume')
|
||||
def test_extend_volume_with_volume_type(self, mock_rpc_extend):
|
||||
elevated = context.get_admin_context()
|
||||
|
@ -2986,9 +2986,15 @@ class VolumeManager(manager.CleanableManager,
|
||||
|
||||
if orig_volume_status == 'in-use':
|
||||
nova_api = compute.API()
|
||||
# If instance_uuid field is None on attachment, it means the
|
||||
# request is coming from glance and not nova
|
||||
instance_uuids = [attachment.instance_uuid
|
||||
for attachment in attachments]
|
||||
nova_api.extend_volume(context, instance_uuids, volume.id)
|
||||
for attachment in attachments
|
||||
if attachment.instance_uuid]
|
||||
# If we are using glance cinder store, we should not send any
|
||||
# external events to nova
|
||||
if instance_uuids:
|
||||
nova_api.extend_volume(context, instance_uuids, volume.id)
|
||||
|
||||
pool = volume_utils.extract_host(volume.host, 'pool')
|
||||
if pool is None:
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`bug #2000724
|
||||
<https://bugs.launchpad.net/cinder/+bug/2000724>`_:
|
||||
Handled the case when glance is calling online extend
|
||||
and externals events were being sent to nova.
|
||||
Now Cinder will only send external events when the volume,
|
||||
to be extended, is attached to a nova instance.
|
Loading…
x
Reference in New Issue
Block a user