Browse Source

Merge "NetApp ONTAP: Fix share size when creating from snapshot" into stable/ocata

tags/4.0.2
Zuul 1 year ago
parent
commit
e9ded083dd

+ 10
- 0
manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py View File

@@ -644,6 +644,16 @@ class NetAppCmodeFileStorageLibrary(object):
644 644
                                            parent_snapshot_name,
645 645
                                            **provisioning_options)
646 646
 
647
+        volume = vserver_client.get_volume(share_name)
648
+        volume_size = int(math.ceil(float(volume['size']) / units.Gi))
649
+        if share['size'] > volume_size:
650
+            LOG.debug("Size of the share requested is larger than the "
651
+                      "snapshot, extending from %(old)sG to %(new)sG" % {
652
+                          'old': volume_size,
653
+                          'new': share['size'],
654
+                      })
655
+            vserver_client.set_volume_size(share_name, share['size'])
656
+
647 657
     @na_utils.trace
648 658
     def _share_exists(self, share_name, vserver_client):
649 659
         return vserver_client.volume_exists(share_name)

+ 24
- 6
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py View File

@@ -920,31 +920,49 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
920 920
                           fake.AGGREGATES[1],
921 921
                           fake.EXTRA_SPEC)
922 922
 
923
-    @ddt.data(None, 'fake_location')
924
-    def test_allocate_container_from_snapshot(self, provider_location):
923
+    @ddt.data({'provider_location': None, 'size': 50},
924
+              {'provider_location': 'fake_location', 'size': 30},
925
+              {'provider_location': 'fake_location', 'size': 20})
926
+    @ddt.unpack
927
+    def test_allocate_container_from_snapshot(self, provider_location, size):
925 928
 
926 929
         self.mock_object(
927 930
             self.library, '_get_provisioning_options_for_share',
928 931
             mock.Mock(return_value=copy.deepcopy(fake.PROVISIONING_OPTIONS)))
929 932
         vserver_client = mock.Mock()
930 933
 
934
+        original_volume = copy.deepcopy(fake.FLEXVOL_TO_MANAGE)
935
+        original_volume['size'] = 32212254720  # 30 GB
936
+        original_volume_size_gb = int(math.ceil(
937
+            float(original_volume['size']) / units.Gi))
938
+
939
+        vserver_client.get_volume.return_value = original_volume
940
+
941
+        fake_share = copy.deepcopy(fake.SHARE)
942
+        fake_share['size'] = size
931 943
         fake_snapshot = copy.deepcopy(fake.SNAPSHOT)
932 944
         fake_snapshot['provider_location'] = provider_location
933 945
 
934
-        self.library._allocate_container_from_snapshot(fake.SHARE,
946
+        self.library._allocate_container_from_snapshot(fake_share,
935 947
                                                        fake_snapshot,
936 948
                                                        vserver_client)
937 949
 
938
-        share_name = self.library._get_backend_share_name(fake.SHARE['id'])
950
+        share_name = self.library._get_backend_share_name(fake_share['id'])
939 951
         parent_share_name = self.library._get_backend_share_name(
940
-            fake.SNAPSHOT['share_id'])
952
+            fake_snapshot['share_id'])
941 953
         parent_snapshot_name = self.library._get_backend_snapshot_name(
942
-            fake.SNAPSHOT['id']) if not provider_location else 'fake_location'
954
+            fake_snapshot['id']) if not provider_location else 'fake_location'
943 955
         vserver_client.create_volume_clone.assert_called_once_with(
944 956
             share_name, parent_share_name, parent_snapshot_name,
945 957
             thin_provisioned=True, snapshot_policy='default',
946 958
             language='en-US', dedup_enabled=True, split=True,
947 959
             compression_enabled=False, max_files=5000)
960
+        vserver_client.get_volume.assert_called_once_with(share_name)
961
+        if size > original_volume_size_gb:
962
+            vserver_client.set_volume_size.assert_called_once_with(
963
+                share_name, size)
964
+        else:
965
+            vserver_client.set_volume_size.assert_not_called()
948 966
 
949 967
     def test_share_exists(self):
950 968
 

+ 5
- 0
releasenotes/notes/bug-1717263-d772366c6a0bce17.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+fixes:
3
+  - The NetApp ONTAP driver has been fixed to honor the share size as
4
+    requested when creating shares from an existing snapshot.
5
+

Loading…
Cancel
Save