From ff55def55b490a16f570265265fa90a29f2c3145 Mon Sep 17 00:00:00 2001 From: Silvan Kaiser Date: Fri, 1 Jun 2018 12:38:19 +0200 Subject: [PATCH] Use volume_uuid in _resize_share of Quobyte Driver Adds resolving the volume name to volume id when resizing and cleans up _resolve_volume_name calls. Closes-Bug: #1774604 Change-Id: I37ecd611c94f9b0019b87d5186f96aed93130f88 --- manila/share/drivers/quobyte/quobyte.py | 33 ++++++++----------- .../share/drivers/quobyte/test_quobyte.py | 8 +++-- ...ug-1774604-qb-driver-b7e717cbc71d6189.yaml | 5 +++ 3 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 releasenotes/notes/bug-1774604-qb-driver-b7e717cbc71d6189.yaml diff --git a/manila/share/drivers/quobyte/quobyte.py b/manila/share/drivers/quobyte/quobyte.py index 55d7eeb9aa..cce58aa98d 100644 --- a/manila/share/drivers/quobyte/quobyte.py +++ b/manila/share/drivers/quobyte/quobyte.py @@ -89,9 +89,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): or CONF.share_backend_name or 'Quobyte') def _fetch_existing_access(self, context, share): - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) result = self.rpc.call('getConfiguration', {}) if result is None: raise exception.QBException( @@ -184,7 +183,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): self.rpc.call('setQuota', {"quotas": [ {"consumer": [{"type": "VOLUME", - "identifier": share["name"], + "identifier": self._resolve_volume_name(share["name"], + share['project_id']), "tenant_id": share["project_id"]}], "limits": [{"type": "LOGICAL_DISK_SPACE", "value": newsize_bytes}]} @@ -223,9 +223,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): raise exception.QBException( _('Quobyte driver only supports NFS shares')) - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) if not volume_uuid: # create tenant, expect ERROR_GARBAGE_ARGS if it already exists @@ -251,9 +250,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): def delete_share(self, context, share, share_server=None): """Delete the corresponding Quobyte volume.""" - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) if not volume_uuid: LOG.warning("No volume found for " "share %(project_id)s/%(name)s", @@ -281,9 +279,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): the backend """ - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) LOG.debug("Ensuring Quobyte share %s", share['name']) @@ -303,9 +300,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): raise exception.InvalidShareAccess( _('Quobyte driver only supports ip access control')) - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) ro = access['access_level'] == (constants.ACCESS_LEVEL_RO) call_params = { "volume_uuid": volume_uuid, @@ -322,9 +318,8 @@ class QuobyteShareDriver(driver.ExecuteMixin, driver.ShareDriver,): self._get_project_name(context, share['project_id'])) return - volume_uuid = self._resolve_volume_name( - share['name'], - self._get_project_name(context, share['project_id'])) + volume_uuid = self._resolve_volume_name(share['name'], + share['project_id']) call_params = { "volume_uuid": volume_uuid, "remove_allow_ip": access['access_to']} diff --git a/manila/tests/share/drivers/quobyte/test_quobyte.py b/manila/tests/share/drivers/quobyte/test_quobyte.py index a43b3c01bc..1da79daaec 100644 --- a/manila/tests/share/drivers/quobyte/test_quobyte.py +++ b/manila/tests/share/drivers/quobyte/test_quobyte.py @@ -416,7 +416,9 @@ class QuobyteShareDriverTestCase(test.TestCase): mock_qsd_resize_share.assert_called_once_with(share=self.share, new_size=2) - def test_resize_share(self): + @mock.patch.object(quobyte.QuobyteShareDriver, "_resolve_volume_name", + return_value="fake_volume_uuid") + def test_resize_share(self, mock_qb_resolv): self._driver.rpc.call = mock.Mock(wraps=fake_rpc_handler) manila_size = 7 newsize_bytes = manila_size * units.Gi @@ -427,7 +429,7 @@ class QuobyteShareDriverTestCase(test.TestCase): "quotas": [{ "consumer": [{ "type": "VOLUME", - "identifier": self.share["name"], + "identifier": "fake_volume_uuid", "tenant_id": self.share["project_id"] }], "limits": [{ @@ -437,6 +439,8 @@ class QuobyteShareDriverTestCase(test.TestCase): }]} self._driver.rpc.call.assert_has_calls([ mock.call('setQuota', exp_params)]) + mock_qb_resolv.assert_called_once_with(self.share['name'], + self.share['project_id']) @mock.patch.object(quobyte.QuobyteShareDriver, "_resolve_volume_name", diff --git a/releasenotes/notes/bug-1774604-qb-driver-b7e717cbc71d6189.yaml b/releasenotes/notes/bug-1774604-qb-driver-b7e717cbc71d6189.yaml new file mode 100644 index 0000000000..f3de72a672 --- /dev/null +++ b/releasenotes/notes/bug-1774604-qb-driver-b7e717cbc71d6189.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed a bug in the Quobyte driver that allowed share resizing to + incorrectly address the share to be resized in the backend.