From 228cd7d32d4ab5326daa463b58b0cd67dd44cd30 Mon Sep 17 00:00:00 2001 From: zfrendo <842557664@qq.com> Date: Mon, 9 Dec 2024 10:03:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=BB=E4=BB=8E?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=85=83=E6=95=B0=E6=8D=AEbug=20#8475?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db_meta/api/cluster/tendbha/storage_tuple.py | 6 ++++-- dbm-ui/backend/flow/utils/mysql/mysql_db_meta.py | 10 +--------- 2 files changed, 5 insertions(+), 11 deletions(-) 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): """