diff --git a/dbm-ui/backend/db_meta/api/cluster/tendbha/storage_tuple.py b/dbm-ui/backend/db_meta/api/cluster/tendbha/storage_tuple.py index 89cd8ef33c..9fc7bb1a82 100644 --- a/dbm-ui/backend/db_meta/api/cluster/tendbha/storage_tuple.py +++ b/dbm-ui/backend/db_meta/api/cluster/tendbha/storage_tuple.py @@ -38,7 +38,7 @@ def remove_storage_tuple(master_ip: str, slave_ip: str, bk_cloud_id: int, port_l @transaction.atomic -def update_storage_tuple(master_ip: str, new_master_ip: str, bk_cloud_id: int, port_list: list): +def update_storage_tuple(master_ip: str, new_master_ip: str, exclude_ip: list, bk_cloud_id: int, port_list: list): for port in port_list: master_storage = StorageInstance.objects.get( machine__ip=master_ip, port=port, machine__bk_cloud_id=bk_cloud_id @@ -46,4 +46,6 @@ def update_storage_tuple(master_ip: str, new_master_ip: str, bk_cloud_id: int, p new_master_storage = StorageInstance.objects.get( machine__ip=new_master_ip, port=port, machine__bk_cloud_id=bk_cloud_id ) - StorageInstanceTuple.objects.filter(ejector=master_storage).update(ejector=new_master_storage) + StorageInstanceTuple.objects.filter(ejector=master_storage).exclude( + receiver__machine__ip__in=exclude_ip + ).update(ejector=new_master_storage) diff --git a/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py b/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py index 9707723ab2..1ae0c6f602 100644 --- a/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py +++ b/dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py @@ -537,18 +537,10 @@ def mysql_migrate_cluster_switch_storage(self): api.cluster.tendbha.storage_tuple.update_storage_tuple( master_ip=self.cluster["old_master_ip"], new_master_ip=self.cluster["new_master_ip"], + exclude_ip=[self.cluster["old_master_ip"], self.cluster["old_slave_ip"]], bk_cloud_id=self.cluster["bk_cloud_id"], port_list=[self.cluster["mysql_port"]], ) - # add new slave 对应关系 - # if self.cluster.get("new_ro_slave_ips"): - # for new_ro_slave_ip in self.cluster["new_ro_slave_ips"]: - # api.cluster.tendbha.storage_tuple.add_storage_tuple( - # master_ip=self.cluster["new_master_ip"], - # slave_ip=new_ro_slave_ip, - # bk_cloud_id=self.cluster["bk_cloud_id"], - # port_list=[self.cluster["master_port"]], - # ) def mysql_migrate_cluster_add_tuple(self): """