Skip to content

Commit

Permalink
feat(redis): Redis脏机器清理 TencentBlueKing#8226
Browse files Browse the repository at this point in the history
  • Loading branch information
xiepaup authored and iSecloud committed Nov 29, 2024
1 parent 36075dd commit 8df7ff3
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, root_id: str, data: Optional[Dict]):
self.precheck()

def precheck(self):
for ip in self.data["infos"]:
for host in self.data["clear_hosts"]:
ip = host["ip"]
proxy_inst = ProxyInstance.objects.filter(
machine__ip=ip, machine__bk_cloud_id=self.data["bk_cloud_id"]
).first()
Expand Down Expand Up @@ -81,9 +82,8 @@ def dirty_machine_clear_flow(self):
"bk_cloud_id":0,
"only_clear_dbmeta":True/False,
"force": True/False,
"infos":[
"a.a.a.a",
"b.b.b.b"
"clear_hosts":[
{"ip":"a.a.a.a"},
]
}
"""
Expand All @@ -99,7 +99,8 @@ def dirty_machine_clear_flow(self):
act_kwargs.bk_cloud_id = self.data["bk_cloud_id"]

sub_pipelines = []
for ip in self.data["infos"]:
for host in self.data["clear_hosts"]:
ip = host["ip"]
params = {
"ip": ip,
"force": self.data.get("force", False),
Expand Down Expand Up @@ -131,7 +132,8 @@ def precheck_4_clean(self):
1. 不能属于任何集群
2. 必须传入正确的 bizID 和 IP
"""
for ip in self.data["infos"]:
for host in self.data["clear_hosts"]:
ip = host["ip"]
try:
host_obj = Machine.objects.get(
ip=ip, bk_cloud_id=self.data["bk_cloud_id"], bk_biz_id=self.data["bk_biz_id"]
Expand Down

0 comments on commit 8df7ff3

Please sign in to comment.