Skip to content

Commit

Permalink
fix: 故障后迁移standby从库域名的获取2 TencentBlueKing#8608
Browse files Browse the repository at this point in the history
  • Loading branch information
zfrendo committed Dec 17, 2024
1 parent b755e60 commit 44d4b9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dbm-ui/backend/db_meta/api/cluster/tendbha/switch_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from backend.db_meta.enums import (
ClusterEntryRole,
ClusterEntryType,
InstanceInnerRole,
InstancePhase,
InstanceRoleInstanceInnerRoleMap,
Expand Down Expand Up @@ -80,6 +81,8 @@ def change_storage_cluster_entry(cluster_id: int, slave_ip: str, new_slave_ip: s
# 如果是standby节点,为了防止主节点故障dbHa切换后。从域名实际上指向的是主节点。需要从主节点读取域名并移除和添加
if slave_storage.is_stand_by is True:
master_storage = cluster.storageinstance_set.get(instance_inner_role=InstanceInnerRole.MASTER.value)
for be in master_storage.bind_entry.filter(role=ClusterEntryRole.SLAVE_ENTRY.value):
for be in master_storage.bind_entry.filter(
cluster_entry_type=ClusterEntryType.DNS.value, role=ClusterEntryRole.SLAVE_ENTRY.value
):
be.storageinstance_set.remove(master_storage)
be.storageinstance_set.add(new_slave_storage)
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ def master_and_slave_switch(

# 移除主 从节点 域名 .如果主库存在从域名,需移除
acts_list = []
for slave_domain in mater_has_slave_dns_list:
for bind_entry in mater_has_slave_dns_list:
acts_list.append(
{
"act_name": _("对主节点移除从域名:{}".format(slave_domain)),
"act_name": _("对主节点移除从域名:{}".format(bind_entry.entry)),
"act_component_code": MySQLDnsManageComponent.code,
"kwargs": asdict(
IpDnsRecordRecycleKwargs(
instance_list=[
"{}{}{}".format(master_storage.machine.ip, IP_PORT_DIVIDER_FOR_DNS, master_storage.port)
],
domain_name=slave_domain,
domain_name=bind_entry.entry,
bk_cloud_id=cluster_info["bk_cloud_id"],
)
),
Expand Down

0 comments on commit 44d4b9a

Please sign in to comment.