Skip to content

Commit a9378be

Browse files
huangwentai-wendeliSecloud
authored andcommitted
feat(redis): 修复redis从库重建没有保存old nodes的问题 #10270
1 parent a2ff92c commit a9378be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dbm-ui/backend/ticket/builders/redis/redis_toolbox_add_slave.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ class RedisAddSlaveFlowBuilder(BaseRedisTicketFlowBuilder):
7777
inner_flow_name = _("Redis 新建从库")
7878
resource_batch_apply_builder = RedisAddSlaveResourceParamBuilder
7979
default_need_itsm = False
80+
need_patch_recycle_host_details = True
8081

8182
def patch_ticket_detail(self):
8283
"""redis_master -> backend_group"""
8384

84-
super().patch_ticket_detail()
8585
master_hosts = get_target_items_from_details(self.ticket.details, match_keys=["bk_host_id"])
8686
id__machine = {
8787
machine.bk_host_id: machine
@@ -94,6 +94,8 @@ def patch_ticket_detail(self):
9494

9595
for info in self.ticket.details["infos"]:
9696
info["resource_spec"] = {}
97+
info["old_nodes"] = {}
98+
info["old_nodes"]["slave"] = []
9799
# 取第一个cluster即可,即使是多集群,也是单机多实例的情况
98100
cluster = id__cluster[info["cluster_ids"][0]]
99101
for pair in info["pairs"]:
@@ -116,6 +118,12 @@ def patch_ticket_detail(self):
116118
pair["redis_slave"]["location_spec"].update(
117119
sub_zone_ids=[master_machine.bk_sub_zone_id], include_or_exclue=True
118120
)
121+
machine_info = Machine.objects.filter(
122+
ip=pair["redis_slave"]["old_slave_ip"], bk_cloud_id=info["bk_cloud_id"]
123+
).values("ip", "bk_biz_id", "bk_host_id", "bk_cloud_id")
124+
if machine_info.exists():
125+
info["old_nodes"]["slave"].append(machine_info[0])
119126
info["resource_spec"][pair["redis_master"]["ip"]] = pair["redis_slave"]
120127

121128
self.ticket.save(update_fields=["details"])
129+
super().patch_ticket_detail()

0 commit comments

Comments
 (0)