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 c64b6a5bfe..640d47c938 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -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): 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 e8495a1414..71f2068fed 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 @@ -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) diff --git a/releasenotes/notes/bug-1957075-fix-replica-promote-autosize-attributes-c180bb7db328bece.yaml b/releasenotes/notes/bug-1957075-fix-replica-promote-autosize-attributes-c180bb7db328bece.yaml new file mode 100644 index 0000000000..4c344a2804 --- /dev/null +++ b/releasenotes/notes/bug-1957075-fix-replica-promote-autosize-attributes-c180bb7db328bece.yaml @@ -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 `_