Skip to content

Commit

Permalink
fix: 修复主从迁移切换后更新指标角色 TencentBlueKing#7590
Browse files Browse the repository at this point in the history
  • Loading branch information
zfrendo committed Oct 25, 2024
1 parent 5a4b1d1 commit 9932426
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 9932426

Please sign in to comment.