Fix extend operation of shrinked share in generic driver
If a share is shrank from 10G to 5G, the volume is still 10G. This share`s size display is 5G, but the share extend newsize must be > 10G in the old code. So, I think only need to perform resize_filesystem when the share extend newsize <= volume size. The volume extension is performed only when new size larger than volume size. Change-Id: I7e49b446445b8005e2eb23e1d439354eb24915e0 Close-Bug: #1639188
This commit is contained in:
parent
bcb064becb
commit
77a0349adc
@ -667,16 +667,18 @@ class GenericShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||||||
helper = self._get_helper(share)
|
helper = self._get_helper(share)
|
||||||
helper.disable_access_for_maintenance(server_details, share['name'])
|
helper.disable_access_for_maintenance(server_details, share['name'])
|
||||||
self._unmount_device(share, server_details)
|
self._unmount_device(share, server_details)
|
||||||
self._detach_volume(self.admin_context, share, server_details)
|
|
||||||
|
|
||||||
volume = self._get_volume(self.admin_context, share['id'])
|
volume = self._get_volume(self.admin_context, share['id'])
|
||||||
volume = self._extend_volume(self.admin_context, volume, new_size)
|
|
||||||
|
|
||||||
volume = self._attach_volume(
|
if int(new_size) > volume['size']:
|
||||||
self.admin_context,
|
self._detach_volume(self.admin_context, share, server_details)
|
||||||
share,
|
volume = self._extend_volume(self.admin_context, volume, new_size)
|
||||||
server_details['instance_id'],
|
|
||||||
volume)
|
volume = self._attach_volume(
|
||||||
|
self.admin_context,
|
||||||
|
share,
|
||||||
|
server_details['instance_id'],
|
||||||
|
volume)
|
||||||
|
|
||||||
self._resize_filesystem(server_details, volume)
|
self._resize_filesystem(server_details, volume)
|
||||||
self._mount_device(share, server_details, volume)
|
self._mount_device(share, server_details, volume)
|
||||||
helper.restore_access_after_maintenance(server_details,
|
helper.restore_access_after_maintenance(server_details,
|
||||||
|
@ -1630,8 +1630,12 @@ class GenericShareDriverTestCase(test.TestCase):
|
|||||||
"fake", "fake"
|
"fake", "fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_extend_share(self):
|
@ddt.data(100, 130, 123)
|
||||||
fake_volume = "fake"
|
def test_extend_share(self, volume_size):
|
||||||
|
fake_volume = {
|
||||||
|
"name": "fake",
|
||||||
|
"size": volume_size,
|
||||||
|
}
|
||||||
fake_share = {
|
fake_share = {
|
||||||
'id': 'fake',
|
'id': 'fake',
|
||||||
'share_proto': 'NFS',
|
'share_proto': 'NFS',
|
||||||
@ -1662,14 +1666,21 @@ class GenericShareDriverTestCase(test.TestCase):
|
|||||||
self._driver.service_instance_manager.get_common_server.called)
|
self._driver.service_instance_manager.get_common_server.called)
|
||||||
self._driver._unmount_device.assert_called_once_with(
|
self._driver._unmount_device.assert_called_once_with(
|
||||||
fake_share, srv_details)
|
fake_share, srv_details)
|
||||||
self._driver._detach_volume.assert_called_once_with(
|
|
||||||
mock.ANY, fake_share, srv_details)
|
|
||||||
self._driver._get_volume.assert_called_once_with(
|
self._driver._get_volume.assert_called_once_with(
|
||||||
mock.ANY, fake_share['id'])
|
mock.ANY, fake_share['id'])
|
||||||
self._driver._extend_volume.assert_called_once_with(
|
|
||||||
mock.ANY, fake_volume, new_size)
|
if new_size > volume_size:
|
||||||
self._driver._attach_volume.assert_called_once_with(
|
self._driver._detach_volume.assert_called_once_with(
|
||||||
mock.ANY, fake_share, srv_details['instance_id'], mock.ANY)
|
mock.ANY, fake_share, srv_details)
|
||||||
|
self._driver._extend_volume.assert_called_once_with(
|
||||||
|
mock.ANY, fake_volume, new_size)
|
||||||
|
self._driver._attach_volume.assert_called_once_with(
|
||||||
|
mock.ANY, fake_share, srv_details['instance_id'], mock.ANY)
|
||||||
|
else:
|
||||||
|
self.assertFalse(self._driver._detach_volume.called)
|
||||||
|
self.assertFalse(self._driver._extend_volume.called)
|
||||||
|
self.assertFalse(self._driver._attach_volume.called)
|
||||||
|
|
||||||
self._helper_nfs.disable_access_for_maintenance.\
|
self._helper_nfs.disable_access_for_maintenance.\
|
||||||
assert_called_once_with(srv_details, 'test_share')
|
assert_called_once_with(srv_details, 'test_share')
|
||||||
self._helper_nfs.restore_access_after_maintenance.\
|
self._helper_nfs.restore_access_after_maintenance.\
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- In the Generic driver, the backing volume size is
|
||||||
|
greater than the share size when the share has been
|
||||||
|
shrunk. So share extend logic in this driver was
|
||||||
|
changed to only extend the backing volume if its
|
||||||
|
size is less than the size of the new, extended share.
|
Loading…
Reference in New Issue
Block a user