[NetApp] Fixed replica promotion to updated autosize attributes

When a volume is created in NetApp ONTAP, it has a few autosize
attributes that are set by default. The values of the attributes
are defined according to the volume type (DP/RW).

During the replica promotion, the types are swaped between source
and destination volumes, but the autosize values were not being
updated. This patch fixes this behavior, calling an autosize reset
after promoting the replica.

Closes-Bug: #1957075
Change-Id: I9a4e5763927b7585a8fbd6b0004d6a123dcd7fae
This commit is contained in:
Nahim Alves de Souza 2022-03-15 13:37:28 +00:00
parent 3b9cfe126f
commit 8896534bb4
3 changed files with 103 additions and 1 deletions

View File

@ -2756,6 +2756,9 @@ class NetAppCmodeFileStorageLibrary(object):
is_dr,
share_server=share_server)
self._update_autosize_attributes_after_promote_replica(
orig_active_replica, new_active_replica, dm_session)
return new_replica_list
def _unmount_orig_active_replica(self, orig_active_replica,
@ -2777,6 +2780,87 @@ class NetAppCmodeFileStorageLibrary(object):
LOG.exception("Could not unmount the original active replica %s.",
orig_active_replica['id'])
def _get_replica_info(self, replica, dm_session):
"""Retrieves a dict with the replica information.
:param replica: Share replica.
:param dm_session: Data Motion session.
:return: A dict with the replica information.
"""
extra_specs = share_types.get_extra_specs_from_share(replica)
provisioning_options = self._get_provisioning_options(extra_specs)
replica_name = self._get_backend_share_name(replica['id'])
vserver = dm_session.get_vserver_from_share(replica)
replica_backend = share_utils.extract_host(replica['host'],
level='backend_name')
replica_client = data_motion.get_client_for_backend(
replica_backend, vserver_name=vserver)
pool_name = share_utils.extract_host(replica['host'], level='pool')
is_flexgroup = self._is_flexgroup_pool(pool_name)
if is_flexgroup:
replica_aggregate = self._get_flexgroup_aggregate_list(pool_name)
else:
replica_aggregate = share_utils.extract_host(
replica['host'], level='pool')
replica_info = {
'client': replica_client,
'aggregate': replica_aggregate,
'name': replica_name,
'provisioning_options': provisioning_options,
}
return replica_info
def _update_autosize_attributes_after_promote_replica(
self, orig_active_replica, new_active_replica, dm_session):
"""Update autosize attributes after replica is promoted"""
# 1. Get the info from original active replica
orig_active_replica_info = self._get_replica_info(
orig_active_replica, dm_session)
# 2. Get the info from the promoted replica (new_active_replica)
new_active_replica_info = self._get_replica_info(
new_active_replica, dm_session)
# 3. Set autosize attributes for orig_active_replica
# Reset the autosize attributes according to the volume type (RW or DP)
orig_active_replica_autosize_attributes = {'reset': 'true'}
orig_provisioning_opts = (
orig_active_replica_info['provisioning_options'])
orig_provisioning_opts['autosize_attributes'] = (
orig_active_replica_autosize_attributes)
orig_active_replica_info['client'].modify_volume(
orig_active_replica_info['aggregate'],
orig_active_replica_info['name'],
**orig_provisioning_opts)
# 4. Set autosize attributes for new_active_replica
# Reset the autosize attributes according to the volume type (RW or DP)
new_active_replica_autosize_attributes = {'reset': 'true'}
new_provisioning_opts = (
new_active_replica_info['provisioning_options'])
new_provisioning_opts['autosize_attributes'] = (
new_active_replica_autosize_attributes)
new_active_replica_info['client'].modify_volume(
new_active_replica_info['aggregate'],
new_active_replica_info['name'],
**new_provisioning_opts)
def _handle_qos_on_replication_change(self, dm_session, new_active_replica,
orig_active_replica, is_dr,
share_server=None):

View File

@ -4373,7 +4373,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=is_readable))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
replicas = self.library.promote_replica(
None, [self.fake_replica, self.fake_replica_2],
self.fake_replica_2, [], share_server=None)
@ -4436,6 +4437,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(
protocol_helper, 'cleanup_demoted_replica',
mock.Mock(side_effect=exception.StorageCommunicationException))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
mock_log = self.mock_object(lib_base.LOG, 'exception')
self.library.promote_replica(
@ -4466,6 +4469,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(
self.library, '_convert_destination_replica_to_independent',
mock.Mock(side_effect=exception.StorageCommunicationException))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
replicas = self.library.promote_replica(
None, [self.fake_replica, self.fake_replica_2],
@ -4509,6 +4514,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
replicas = self.library.promote_replica(
None, [self.fake_replica, self.fake_replica_2, fake_replica_3],
@ -4565,6 +4572,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
replicas = self.library.promote_replica(
None, [self.fake_replica, self.fake_replica_2],
@ -4794,6 +4803,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
self.mock_object(self.library,
'_is_readable_replica',
mock.Mock(return_value=False))
self.mock_object(self.library,
'_update_autosize_attributes_after_promote_replica')
replicas = self.library.promote_replica(
None, [self.fake_replica, self.fake_replica_2],
self.fake_replica_2, fake_access_rules, share_server=None)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
NetApp driver: Fixed the issue with replica promotion where the autosize
attributes were not being updated on ONTAP. Now, the autosize attributes
are updated after promoting the replica. For more details, please refer to
`launchpad bug #1957075 <https://bugs.launchpad.net/manila/+bug/1957075>`_