Merge "[NetApp]: Fix issues with managed snapshot"
This commit is contained in:
commit
72f232dd48
manila
share/drivers/netapp/dataontap/cluster_mode
tests/share/drivers/netapp/dataontap/cluster_mode
releasenotes/notes
@ -2042,7 +2042,13 @@ class NetAppCmodeFileStorageLibrary(object):
|
||||
@na_utils.trace
|
||||
def manage_existing_snapshot(
|
||||
self, snapshot, driver_options, share_server=None):
|
||||
"""Brings an existing snapshot under Manila management."""
|
||||
"""Brings an existing snapshot under Manila management.
|
||||
|
||||
The managed snapshot keeps with its name, not renaming to the driver
|
||||
snapshot name pattern (share_snapshot_<id>), because the rename is lost
|
||||
when reverting to the snapshot, causing some issues (bug #1936648).
|
||||
"""
|
||||
|
||||
vserver, vserver_client = self._get_vserver(share_server=share_server)
|
||||
share_name = self._get_backend_share_name(snapshot['share_id'])
|
||||
existing_snapshot_name = snapshot.get('provider_location')
|
||||
@ -2078,32 +2084,8 @@ class NetAppCmodeFileStorageLibrary(object):
|
||||
|
||||
# When calculating the size, round up to the next GB.
|
||||
size = int(math.ceil(float(volume['size']) / units.Gi))
|
||||
update_info = {'size': size}
|
||||
|
||||
# NOTE(felipe_rodrigues): ONTAP does not support rename FlexGroup
|
||||
# snapshots, so those managed snapshots will keep the previous name
|
||||
# being referenced by its provider_location field.
|
||||
is_flexgroup = na_utils.is_style_extended_flexgroup(
|
||||
volume['style-extended'])
|
||||
if not is_flexgroup:
|
||||
new_snapshot_name = self._get_backend_snapshot_name(snapshot['id'])
|
||||
update_info['provider_location'] = new_snapshot_name
|
||||
|
||||
try:
|
||||
vserver_client.rename_snapshot(share_name,
|
||||
existing_snapshot_name,
|
||||
new_snapshot_name)
|
||||
except netapp_api.NaApiError:
|
||||
msg = _('Could not rename snapshot %(snap)s in share %(vol)s.')
|
||||
msg_args = {'snap': existing_snapshot_name, 'vol': share_name}
|
||||
raise exception.ManageInvalidShareSnapshot(
|
||||
reason=msg % msg_args)
|
||||
|
||||
# Save original snapshot info to private storage.
|
||||
original_data = {'original_name': existing_snapshot_name}
|
||||
self.private_storage.update(snapshot['id'], original_data)
|
||||
|
||||
return update_info
|
||||
return {'size': size}
|
||||
|
||||
@na_utils.trace
|
||||
def unmanage_snapshot(self, snapshot, share_server=None):
|
||||
|
@ -3005,9 +3005,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
||||
vserver_client.get_volume.return_value = fake.FLEXVOL_TO_MANAGE
|
||||
vserver_client.snapshot_exists.return_value = True
|
||||
vserver_client.volume_has_snapmirror_relationships.return_value = False
|
||||
self.mock_object(
|
||||
na_utils, 'is_style_extended_flexgroup',
|
||||
mock.Mock(return_value=is_flexgroup))
|
||||
|
||||
result = self.library.manage_existing_snapshot(
|
||||
fake.SNAPSHOT_TO_MANAGE, {}, share_server=fake_vserver)
|
||||
@ -3019,20 +3016,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
||||
fake.SNAPSHOT_NAME, share_name)
|
||||
(vserver_client.volume_has_snapmirror_relationships.
|
||||
assert_called_once_with(fake.FLEXVOL_TO_MANAGE))
|
||||
na_utils.is_style_extended_flexgroup.assert_called_once_with(
|
||||
fake.FLEXGROUP_STYLE_EXTENDED)
|
||||
expected_result = {'size': 2}
|
||||
if is_flexgroup:
|
||||
vserver_client.rename_snapshot.assert_not_called()
|
||||
self.library.private_storage.update.assert_not_called()
|
||||
else:
|
||||
new_snapshot_name = self.library._get_backend_snapshot_name(
|
||||
fake.SNAPSHOT['id'])
|
||||
vserver_client.rename_snapshot.assert_called_once_with(
|
||||
share_name, fake.SNAPSHOT_NAME, new_snapshot_name)
|
||||
self.library.private_storage.update.assert_called_once_with(
|
||||
fake.SNAPSHOT['id'], {'original_name': fake.SNAPSHOT_NAME})
|
||||
expected_result['provider_location'] = new_snapshot_name
|
||||
self.assertEqual(expected_result, result)
|
||||
|
||||
def test_manage_existing_snapshot_no_snapshot_name(self):
|
||||
@ -3099,24 +3083,6 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
|
||||
self.library.manage_existing_snapshot,
|
||||
fake.SNAPSHOT_TO_MANAGE, {})
|
||||
|
||||
def test_manage_existing_snapshot_rename_snapshot_error(self):
|
||||
|
||||
vserver_client = mock.Mock()
|
||||
self.mock_object(self.library,
|
||||
'_get_vserver',
|
||||
mock.Mock(return_value=(fake.VSERVER1,
|
||||
vserver_client)))
|
||||
vserver_client.get_volume.return_value = fake.FLEXVOL_TO_MANAGE
|
||||
vserver_client.volume_has_snapmirror_relationships.return_value = False
|
||||
self.mock_object(
|
||||
na_utils, 'is_style_extended_flexgroup',
|
||||
mock.Mock(return_value=False))
|
||||
vserver_client.rename_snapshot.side_effect = netapp_api.NaApiError
|
||||
|
||||
self.assertRaises(exception.ManageInvalidShareSnapshot,
|
||||
self.library.manage_existing_snapshot,
|
||||
fake.SNAPSHOT_TO_MANAGE, {})
|
||||
|
||||
@ddt.data(None, fake.VSERVER1)
|
||||
def test_unmanage_snapshot(self, fake_vserver):
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
NetApp driver: fix some issues caused with managed snapshot, it is no more
|
||||
renaming the managed snapshot. For more details, please refer to
|
||||
`launchpad bug #1936648 <https://bugs.launchpad.net/manila/+bug/1936648>`_
|
Loading…
x
Reference in New Issue
Block a user