Disallow extension of attached volumes for NFS & Quobyte drivers
NFS and Quobyte drivers no longer allow extension of an attached volume. The extend operation raises an ExtendVolumeError in the Cinder Volume service in case the volume to be extended is currently attached. This should be reverted once a a more capable solution for bug #1870367 has been found. Partial-bug: #1870367 Change-Id: Ib2a7c1cdf269b4907ff8adff1b9d900072eedde2
This commit is contained in:
parent
e82ff57b70
commit
57892623de
@ -997,6 +997,28 @@ class NfsDriverTestCase(test.TestCase):
|
||||
resize.assert_called_once_with(path, newSize,
|
||||
run_as_root=True)
|
||||
|
||||
def test_extend_volume_attached_fail(self):
|
||||
"""Extend a volume by 1."""
|
||||
self._set_driver()
|
||||
drv = self._driver
|
||||
volume = fake_volume.fake_volume_obj(
|
||||
self.context,
|
||||
id='80ee16b6-75d2-4d54-9539-ffc1b4b0fb10',
|
||||
size=1,
|
||||
provider_location='nfs_share')
|
||||
path = 'path'
|
||||
newSize = volume['size'] + 1
|
||||
|
||||
with mock.patch.object(drv, 'local_path', return_value=path):
|
||||
with mock.patch.object(drv, '_is_share_eligible',
|
||||
return_value=True):
|
||||
with mock.patch.object(drv, '_is_file_size_equal',
|
||||
return_value=True):
|
||||
with mock.patch.object(drv, '_is_volume_attached',
|
||||
return_value=True):
|
||||
self.assertRaises(exception.ExtendVolumeError,
|
||||
drv.extend_volume, volume, newSize)
|
||||
|
||||
def test_extend_volume_failure(self):
|
||||
"""Error during extend operation."""
|
||||
self._set_driver()
|
||||
|
@ -927,7 +927,10 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
drv._ensure_share_mounted.assert_not_called()
|
||||
drv._execute.assert_not_called()
|
||||
|
||||
def test_extend_volume(self):
|
||||
@ddt.data(True, False)
|
||||
@mock.patch.object(remotefs.RemoteFSSnapDriverDistributed,
|
||||
"_is_volume_attached")
|
||||
def test_extend_volume(self, is_attached, mock_remote_attached):
|
||||
drv = self._driver
|
||||
|
||||
volume = self._simple_volume()
|
||||
@ -948,12 +951,19 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
image_utils.qemu_img_info = mock.Mock(return_value=img_info)
|
||||
image_utils.resize_image = mock.Mock()
|
||||
|
||||
drv.extend_volume(volume, 3)
|
||||
mock_remote_attached.return_value = is_attached
|
||||
|
||||
image_utils.qemu_img_info.assert_called_once_with(volume_path,
|
||||
force_share=True,
|
||||
run_as_root=False)
|
||||
image_utils.resize_image.assert_called_once_with(volume_path, 3)
|
||||
if is_attached:
|
||||
self.assertRaises(exception.ExtendVolumeError, drv.extend_volume,
|
||||
volume, 3)
|
||||
else:
|
||||
drv.extend_volume(volume, 3)
|
||||
|
||||
image_utils.qemu_img_info.assert_called_once_with(volume_path,
|
||||
force_share=True,
|
||||
run_as_root=False
|
||||
)
|
||||
image_utils.resize_image.assert_called_once_with(volume_path, 3)
|
||||
|
||||
def test_copy_volume_from_snapshot(self):
|
||||
drv = self._driver
|
||||
|
@ -363,6 +363,12 @@ class NfsDriver(remotefs.RemoteFSSnapDriverDistributed):
|
||||
|
||||
def extend_volume(self, volume, new_size):
|
||||
"""Extend an existing volume to the new size."""
|
||||
if self._is_volume_attached(volume):
|
||||
# NOTE(kaisers): no attached extensions until #1870367 is fixed
|
||||
msg = (_("Cannot extend volume %s while it is attached.")
|
||||
% volume['id'])
|
||||
raise exception.ExtendVolumeError(msg)
|
||||
|
||||
LOG.info('Extending volume %s.', volume.id)
|
||||
extend_by = int(new_size) - volume.size
|
||||
if not self._is_share_eligible(volume.provider_location,
|
||||
|
@ -540,6 +540,12 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
|
||||
|
||||
@utils.synchronized('quobyte', external=False)
|
||||
def extend_volume(self, volume, size_gb):
|
||||
if self._is_volume_attached(volume):
|
||||
# NOTE(kaisers): no attached extensions until #1870367 is fixed
|
||||
msg = (_("Cannot extend volume %s while it is attached.")
|
||||
% volume['id'])
|
||||
raise exception.ExtendVolumeError(msg)
|
||||
|
||||
volume_path = self.local_path(volume)
|
||||
|
||||
info = self._qemu_img_info(volume_path, volume.name)
|
||||
|
@ -298,12 +298,12 @@ driver.nec=complete
|
||||
driver.netapp_ontap=missing
|
||||
driver.netapp_solidfire=complete
|
||||
driver.nexenta=complete
|
||||
driver.nfs=complete
|
||||
driver.nfs=missing
|
||||
driver.nimble=complete
|
||||
driver.prophetstor=complete
|
||||
driver.pure=complete
|
||||
driver.qnap=complete
|
||||
driver.quobyte=complete
|
||||
driver.quobyte=missing
|
||||
driver.rbd=complete
|
||||
driver.sandstone=complete
|
||||
driver.seagate=complete
|
||||
|
7
releasenotes/notes/bug_1870367-49b74d10a9bfcf07.yaml
Normal file
7
releasenotes/notes/bug_1870367-49b74d10a9bfcf07.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`Bug #1870367 <https://bugs.launchpad.net/cinder/+bug/1870367>`_ :
|
||||
Partially fixed NFS and Quobyte drivers by no longer allowing extending a
|
||||
volume while it is attached, to prevent failures due to Qemu internal
|
||||
locking mechanisms.
|
Loading…
Reference in New Issue
Block a user