From 4b63f091f82d7ed217553d8646754768d8a5b243 Mon Sep 17 00:00:00 2001 From: yuanruji Date: Tue, 19 Nov 2024 18:57:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E5=A4=84=E7=90=86=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=A3=80=E6=9F=A5=E5=8F=82=E6=95=B0=20#8048?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bamboo/scene/mysql/common/master_and_slave_switch.py | 6 ++++-- .../flow/engine/bamboo/scene/mysql/mysql_ha_upgrade.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/common/master_and_slave_switch.py b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/common/master_and_slave_switch.py index 5a1373e463..081e726df1 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/common/master_and_slave_switch.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/common/master_and_slave_switch.py @@ -43,7 +43,9 @@ logger = logging.getLogger("flow") -def master_and_slave_switch(root_id: str, ticket_data: dict, cluster: Cluster, cluster_info: dict): +def master_and_slave_switch( + root_id: str, ticket_data: dict, cluster: Cluster, cluster_info: dict, check_client_conn=True +): """ 定义成对迁移完成,做成对切换的子流程(子流程是已集群维度做成对切换) 成对切换更多解决一主一从的集群机器裁撤场景;对于一主多从的集群, @@ -81,7 +83,7 @@ def master_and_slave_switch(root_id: str, ticket_data: dict, cluster: Cluster, c uid=ticket_data["uid"], root_id=root_id, cluster=cluster, - is_check_client_conn=True, + is_check_client_conn=check_client_conn, is_verify_checksum=True, check_client_conn_inst=[ f"{cluster_info['old_master_ip']}{IP_PORT_DIVIDER}{cluster_info['mysql_port']}", diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_ha_upgrade.py b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_ha_upgrade.py index a6216ca574..a9cd6d1b99 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_ha_upgrade.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_ha_upgrade.py @@ -170,6 +170,7 @@ def __init__(self, root_id: str, ticket_data: Optional[Dict]): self.ticket_data = ticket_data # 仅添加从库。不切换。不复制账号 self.add_slave_only = self.ticket_data.get("add_slave_only", False) + self.check_client_conn = not self.ticket_data.get("force", False) def __precheck(self): """ @@ -301,6 +302,7 @@ def upgrade_tendbha_cluster(self): created_by=created_by, force_uninstall=False, ticket_type=self.ticket_data["ticket_type"], + check_client_conn=self.check_client_conn, ) subflows.append(subflow) @@ -322,6 +324,7 @@ def tendbha_cluster_upgrade_subflow( created_by: str, force_uninstall: bool, ticket_type: str, + check_client_conn: bool, ): """ 一主多从,整个集群升级 @@ -515,6 +518,7 @@ def tendbha_cluster_upgrade_subflow( new_slave_ip=new_slave_ip, old_ro_slave_ips=old_ro_slave_ips, new_ro_slave_ips=new_ro_slave_ips, + check_client_conn=check_client_conn, ) sub_pipeline.add_parallel_sub_pipeline(sub_flow_list=ms_switch_subflows) # 清理实例级别周边配置 @@ -1139,6 +1143,7 @@ def build_ms_pair_switch_sub_pipelines( new_slave_ip: str, old_ro_slave_ips: list, new_ro_slave_ips: list, + check_client_conn: bool, ): switch_sub_pipeline_list = [] for cluster_id in relation_cluster_ids: @@ -1167,6 +1172,7 @@ def build_ms_pair_switch_sub_pipelines( ticket_data=copy.deepcopy(parent_global_data), cluster=cluster_model, cluster_info=copy.deepcopy(cluster_info), + check_client_conn=check_client_conn, ) ) switch_sub_pipeline.add_act(