diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py index 720ab79947..609107bd56 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -644,6 +644,16 @@ class NetAppCmodeFileStorageLibrary(object): parent_snapshot_name, **provisioning_options) + volume = vserver_client.get_volume(share_name) + volume_size = int(math.ceil(float(volume['size']) / units.Gi)) + if share['size'] > volume_size: + LOG.debug("Size of the share requested is larger than the " + "snapshot, extending from %(old)sG to %(new)sG" % { + 'old': volume_size, + 'new': share['size'], + }) + vserver_client.set_volume_size(share_name, share['size']) + @na_utils.trace def _share_exists(self, share_name, vserver_client): return vserver_client.volume_exists(share_name) diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py index b4cf0d770a..b2cd440d0b 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py @@ -920,31 +920,49 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): fake.AGGREGATES[1], fake.EXTRA_SPEC) - @ddt.data(None, 'fake_location') - def test_allocate_container_from_snapshot(self, provider_location): + @ddt.data({'provider_location': None, 'size': 50}, + {'provider_location': 'fake_location', 'size': 30}, + {'provider_location': 'fake_location', 'size': 20}) + @ddt.unpack + def test_allocate_container_from_snapshot(self, provider_location, size): self.mock_object( self.library, '_get_provisioning_options_for_share', mock.Mock(return_value=copy.deepcopy(fake.PROVISIONING_OPTIONS))) vserver_client = mock.Mock() + original_volume = copy.deepcopy(fake.FLEXVOL_TO_MANAGE) + original_volume['size'] = 32212254720 # 30 GB + original_volume_size_gb = int(math.ceil( + float(original_volume['size']) / units.Gi)) + + vserver_client.get_volume.return_value = original_volume + + fake_share = copy.deepcopy(fake.SHARE) + fake_share['size'] = size fake_snapshot = copy.deepcopy(fake.SNAPSHOT) fake_snapshot['provider_location'] = provider_location - self.library._allocate_container_from_snapshot(fake.SHARE, + self.library._allocate_container_from_snapshot(fake_share, fake_snapshot, vserver_client) - share_name = self.library._get_backend_share_name(fake.SHARE['id']) + share_name = self.library._get_backend_share_name(fake_share['id']) parent_share_name = self.library._get_backend_share_name( - fake.SNAPSHOT['share_id']) + fake_snapshot['share_id']) parent_snapshot_name = self.library._get_backend_snapshot_name( - fake.SNAPSHOT['id']) if not provider_location else 'fake_location' + fake_snapshot['id']) if not provider_location else 'fake_location' vserver_client.create_volume_clone.assert_called_once_with( share_name, parent_share_name, parent_snapshot_name, thin_provisioned=True, snapshot_policy='default', language='en-US', dedup_enabled=True, split=True, compression_enabled=False, max_files=5000) + vserver_client.get_volume.assert_called_once_with(share_name) + if size > original_volume_size_gb: + vserver_client.set_volume_size.assert_called_once_with( + share_name, size) + else: + vserver_client.set_volume_size.assert_not_called() def test_share_exists(self): diff --git a/releasenotes/notes/bug-1717263-d772366c6a0bce17.yaml b/releasenotes/notes/bug-1717263-d772366c6a0bce17.yaml new file mode 100644 index 0000000000..5a29adc666 --- /dev/null +++ b/releasenotes/notes/bug-1717263-d772366c6a0bce17.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - The NetApp ONTAP driver has been fixed to honor the share size as + requested when creating shares from an existing snapshot. +