NetApp ONTAP: Fix share size when creating from snapshot

The ONTAP driver was ignoring the size requested when
creating a share from an existing snapshot.

Closes-Bug: #1717263
Change-Id: I335f72a8dea49d5855201fc63a7ac22240b60bbf
(cherry picked from commit 0531a1a9ef)
This commit is contained in:
tpsilva 2017-10-10 14:30:47 -03:00 committed by Goutham Pacha Ravi
parent 91dbbb4d15
commit b14d3513db
4 changed files with 33 additions and 10 deletions

View File

@ -720,6 +720,8 @@ class NetAppCmodeFileStorageLibrary(object):
vserver_client.create_volume_clone(share_name, parent_share_name,
parent_snapshot_name,
**provisioning_options)
if share['size'] > snapshot['size']:
vserver_client.set_volume_size(share_name, share['size'])
@na_utils.trace
def _share_exists(self, share_name, vserver_client):
@ -1154,7 +1156,8 @@ class NetAppCmodeFileStorageLibrary(object):
cgsnapshot_member['id']):
clone_info['snapshot'] = {
'share_id': cgsnapshot_member['share_id'],
'id': cgsnapshot_dict['id']
'id': cgsnapshot_dict['id'],
'size': cgsnapshot_member['size'],
}
break

View File

@ -1014,35 +1014,47 @@ 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):
mock_get_provisioning_opts = self.mock_object(
self.library, '_get_provisioning_options_for_share',
mock.Mock(return_value=copy.deepcopy(fake.PROVISIONING_OPTIONS)))
vserver = fake.VSERVER1
vserver_client = mock.Mock()
original_snapshot_size = 20
fake_share = copy.deepcopy(fake.SHARE)
fake_share['size'] = size
fake_snapshot = copy.deepcopy(fake.SNAPSHOT)
fake_snapshot['provider_location'] = provider_location
fake_snapshot['size'] = original_snapshot_size
self.library._allocate_container_from_snapshot(fake.SHARE,
self.library._allocate_container_from_snapshot(fake_share,
fake_snapshot,
vserver,
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'
mock_get_provisioning_opts.assert_called_once_with(
fake.SHARE, fake.VSERVER1)
fake_share, fake.VSERVER1)
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)
if size > original_snapshot_size:
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):

View File

@ -452,6 +452,7 @@ CG_SNAPSHOT_MEMBER_1 = {
'id': CG_SNAPSHOT_MEMBER_ID1,
'share_id': SHARE_ID,
'share_proto': 'NFS',
'size': SHARE_SIZE,
}
CG_SNAPSHOT_MEMBER_2 = {
@ -459,6 +460,7 @@ CG_SNAPSHOT_MEMBER_2 = {
'id': CG_SNAPSHOT_MEMBER_ID2,
'share_id': SHARE_ID2,
'share_proto': 'NFS',
'size': SHARE_SIZE,
}
CG_SNAPSHOT = {
@ -475,14 +477,16 @@ COLLATED_CGSNAPSHOT_INFO = [
'share': SHARE_FOR_CG3,
'snapshot': {
'share_id': SHARE_ID,
'id': CG_SNAPSHOT_ID
'id': CG_SNAPSHOT_ID,
'size': SHARE_SIZE,
}
},
{
'share': SHARE_FOR_CG4,
'snapshot': {
'share_id': SHARE_ID2,
'id': CG_SNAPSHOT_ID
'id': CG_SNAPSHOT_ID,
'size': SHARE_SIZE,
}
},
]

View File

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