diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py index c89b5e0ee3..8c30f140d0 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_multi_svm.py @@ -558,7 +558,6 @@ class NetAppCmodeMultiSVMFileStorageLibrary( node_network_info = zip(nodes, network_info['network_allocations']) for node_name, network_allocation in node_network_info: - port = self._get_node_data_port(node_name) vlan = network_allocation['segmentation_id'] network_mtu = network_allocation.get('mtu') @@ -741,12 +740,24 @@ class NetAppCmodeMultiSVMFileStorageLibrary( super(NetAppCmodeMultiSVMFileStorageLibrary, self).delete_replica( context, replica_list, replica, share_snapshots) + # Fix for bug 1996907- If snapmirror relationship still exist, + # deletes those again. + snapmirrors_des_list = self._get_snapmirrors_destinations( + vserver, peer_vserver) + snapmirrors_des_list_from_peer = self._get_snapmirrors_destinations( + peer_vserver, vserver) + if snapmirrors_des_list or snapmirrors_des_list_from_peer: + super(NetAppCmodeMultiSVMFileStorageLibrary, self).delete_replica( + context, replica_list, replica, share_snapshots) + # Check if there are no remaining SnapMirror connections and if a # vserver peering exists and delete it. - snapmirrors = self._get_snapmirrors(vserver, peer_vserver) + snapmirrors_from_local = self._get_snapmirrors(vserver, peer_vserver) snapmirrors_from_peer = self._get_snapmirrors(peer_vserver, vserver) peers = self._get_vserver_peers(peer_vserver, vserver) - if not (snapmirrors or snapmirrors_from_peer) and peers: + if (not (snapmirrors_from_local or snapmirrors_from_peer + or snapmirrors_des_list or snapmirrors_des_list_from_peer) + and peers): self._delete_vserver_peer(peer_vserver, vserver) def manage_server(self, context, share_server, identifier, driver_options): @@ -795,6 +806,10 @@ class NetAppCmodeMultiSVMFileStorageLibrary( return self._client.get_snapmirrors( source_vserver=vserver, dest_vserver=peer_vserver) + def _get_snapmirrors_destinations(self, vserver, peer_vserver): + return self._client.get_snapmirror_destinations( + source_vserver=vserver, dest_vserver=peer_vserver) + def _get_vservers_from_replicas(self, context, replica_list, new_replica): active_replica = self.find_active_replica(replica_list) @@ -1175,6 +1190,7 @@ class NetAppCmodeMultiSVMFileStorageLibrary( LOG.debug( msg, {'operation_id': operation_id, 'status': status}) return + try: wait_for_status() except exception.NetAppException: @@ -2109,9 +2125,9 @@ class NetAppCmodeMultiSVMFileStorageLibrary( raise exception.NetAppException(msg) (super(NetAppCmodeMultiSVMFileStorageLibrary, self) - .validate_provisioning_options_for_share(provisioning_options, - extra_specs=extra_specs, - qos_specs=qos_specs)) + .validate_provisioning_options_for_share(provisioning_options, + extra_specs=extra_specs, + qos_specs=qos_specs)) def _get_different_keys_for_equal_ss_type(self, current_sec_service, new_sec_service): diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py index 358dfcc98b..fdfce85252 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_multi_svm.py @@ -1478,6 +1478,8 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): mock.Mock(return_value=(self.fake_vserver, self.fake_new_vserver_name))) self.mock_object(base_class, 'delete_replica') + self.mock_object(self.library, '_get_snapmirrors_destinations', + mock.Mock(return_value=[])) self.mock_object(self.library, '_get_snapmirrors', mock.Mock(return_value=[])) self.mock_object(self.library, '_get_vserver_peers', @@ -1491,6 +1493,10 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): self.library._get_vservers_from_replicas.assert_called_once_with( None, [self.fake_replica], self.fake_new_replica ) + self.library._get_snapmirrors_destinations.assert_has_calls( + [mock.call(self.fake_vserver, self.fake_new_vserver_name), + mock.call(self.fake_new_vserver_name, self.fake_vserver)] + ) base_class.delete_replica.assert_called_once_with( None, [self.fake_replica], self.fake_new_replica, [] ) @@ -1602,6 +1608,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): class FakeDBObj(dict): def to_dict(self): return self + fake_parent_share = copy.deepcopy(fake.SHARE) fake_parent_share['id'] = fake.SHARE_ID2 fake_parent_share['host'] = fake.MANILA_HOST_NAME_2 @@ -1826,11 +1833,11 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): @ddt.data( {'expected_server': fake.SHARE_SERVER_NO_NFS_NONE, - 'share_group': {'share_server_id': - fake.SHARE_SERVER_NO_NFS_NONE['id']}}, + 'share_group': { + 'share_server_id': fake.SHARE_SERVER_NO_NFS_NONE['id']}}, {'expected_server': fake.SHARE_SERVER_NO_DETAILS, - 'share_group': {'share_server_id': - fake.SHARE_SERVER_NO_DETAILS['id']}}, + 'share_group': { + 'share_server_id': fake.SHARE_SERVER_NO_DETAILS['id']}}, {'expected_server': fake.SHARE_SERVER_NO_DETAILS, 'share_group': { 'share_server_id': fake.SHARE_SERVER_NO_DETAILS['id']}, @@ -2857,7 +2864,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase): @ddt.data({'mirror_state': 'snapmirrored', 'status': 'idle'}, {'mirror_state': 'uninitialized', 'status': 'transferring'}, - {'mirror_state': 'snapmirrored', 'status': 'quiescing'},) + {'mirror_state': 'snapmirrored', 'status': 'quiescing'}, ) @ddt.unpack def test_share_server_migration_continue_svm_dr(self, mirror_state, status): diff --git a/releasenotes/notes/bug-1982808-fix-netapp-api-failed-relationship-is-in-use-ecc9ede4d7f0f5b9.yaml b/releasenotes/notes/bug-1982808-fix-netapp-api-failed-relationship-is-in-use-ecc9ede4d7f0f5b9.yaml new file mode 100644 index 0000000000..92a4587278 --- /dev/null +++ b/releasenotes/notes/bug-1982808-fix-netapp-api-failed-relationship-is-in-use-ecc9ede4d7f0f5b9.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + NetApp driver `bug #1982808 + `_: Fixed issue + to add the retry logic to delete and release the snapmirror relationship. + Delete the vserver pairing when there is no snapmirror relationship exist + on source and destination cluster.