From 99324262c0a1f3358131c4a3a1fa5dbe5a8ec58a Mon Sep 17 00:00:00 2001 From: zfrendo <842557664@qq.com> Date: Fri, 25 Oct 2024 15:34:34 +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=88=87=E6=8D=A2=E5=90=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=A7=92=E8=89=B2=20#7590?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cluster/tendbcluster/remotedb_node_migrate.py | 5 +++++ .../db_meta/api/cluster/tendbha/switch_storage.py | 14 +++++++------- .../mysql/mysql_migrate_cluster_remote_flow.py | 10 ++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py b/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py index a7d1c524f2..619cac0c41 100644 --- a/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py +++ b/dbm-ui/backend/db_meta/api/cluster/tendbcluster/remotedb_node_migrate.py @@ -139,6 +139,11 @@ def switch_remote_node(cls, cluster_id: int, source: dict, target: dict): ) storage_shard.storage_instance_tuple = target_tuple storage_shard.save() + cc_topo_operator = MysqlCCTopoOperator(cluster) + cc_topo_operator.is_bk_module_created = True + cc_topo_operator.transfer_instances_to_cluster_module( + instances=[target_master_obj, target_slave_obj], is_increment=True + ) @classmethod @transaction.atomic diff --git a/dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py b/dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py index 0df679223a..c09716641b 100644 --- a/dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py +++ b/dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py @@ -12,7 +12,7 @@ from django.db import transaction -from backend.db_meta.enums import InstanceRole, InstanceRoleInstanceInnerRoleMap, InstanceStatus +from backend.db_meta.enums import InstanceRoleInstanceInnerRoleMap, InstanceStatus from backend.db_meta.models import Cluster, StorageInstance from backend.flow.utils.mysql.mysql_module_operate import MysqlCCTopoOperator @@ -34,19 +34,19 @@ def switch_storage(cluster_id: int, target_storage_ip: str, origin_storage_ip: s ) cluster.storageinstance_set.remove(origin_storage) target_storage.status = InstanceStatus.RUNNING.value - if role and target_storage.instance_role == InstanceRole.BACKEND_REPEATER.value: + # target实例需要继承source实例的is_standby特性 + target_storage.is_stand_by = origin_storage.is_stand_by + if role: # 如果是REPEATER角色,改成传入的role变量 target_storage.instance_role = role target_storage.instance_inner_role = InstanceRoleInstanceInnerRoleMap[role].value - + target_storage.save() # 更新cmdb标签状态 cc_topo_operator = MysqlCCTopoOperator(cluster) cc_topo_operator.is_bk_module_created = True cc_topo_operator.transfer_instances_to_cluster_module(instances=[target_storage], is_increment=True) - - # target实例需要继承source实例的is_standby特性 - target_storage.is_stand_by = origin_storage.is_stand_by - target_storage.save() + else: + target_storage.save() def change_proxy_storage_entry(cluster_id: int, master_ip: str, new_master_ip: str): diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_migrate_cluster_remote_flow.py b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_migrate_cluster_remote_flow.py index 1a68026278..7d21403d1f 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_migrate_cluster_remote_flow.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_migrate_cluster_remote_flow.py @@ -290,7 +290,9 @@ def migrate_cluster_flow(self, use_for_upgrade=False): ) ), ) - sync_data_sub_pipeline_list.append(sync_data_sub_pipeline.build_sub_process(sub_name=_("恢复实例数据"))) + sync_data_sub_pipeline_list.append( + sync_data_sub_pipeline.build_sub_process(sub_name=_("{} 集群恢复数据".format(cluster_model.name))) + ) switch_sub_pipeline_list = [] for cluster_id in self.data["cluster_ids"]: @@ -504,7 +506,11 @@ def migrate_cluster_flow(self, use_for_upgrade=False): tendb_migrate_pipeline.add_act(act_name=_("人工确认卸载实例"), act_component_code=PauseComponent.code, kwargs={}) # 卸载remote节点 tendb_migrate_pipeline.add_parallel_sub_pipeline(sub_flow_list=uninstall_svr_sub_pipeline_list) - tendb_migrate_pipeline_list.append(tendb_migrate_pipeline.build_sub_process(sub_name=_("集群开始成对迁移"))) + tendb_migrate_pipeline_list.append( + tendb_migrate_pipeline.build_sub_process( + sub_name=_("{} > {} 成对迁移".format(self.data["master_ip"], self.data["new_master_ip"])) + ) + ) # 运行流程 tendb_migrate_pipeline_all.add_parallel_sub_pipeline(tendb_migrate_pipeline_list) tendb_migrate_pipeline_all.run_pipeline(