Skip to content

Commit

Permalink
feat(redis): 优化【检查切换状态】: Argument list too long #7677
Browse files Browse the repository at this point in the history
  • Loading branch information
xiepaup authored and iSecloud committed Nov 15, 2024
1 parent c1c0710 commit ccff2fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dbm-ui/backend/db_meta/api/cluster/nosqlcomm/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def get_cluster_detail(cluster_id: int):

def get_cluster_proxies(cluster_id: int):
try:
cluster_obj = Cluster.objects.get(id=cluster_id)
cluster_obj = Cluster.objects.prefetch_related(
"proxyinstance_set",
"proxyinstance_set__machine",
).get(id=cluster_id)
return [
{"ip": proxy_obj.machine.ip, "port": proxy_obj.port, "admin_port": proxy_obj.admin_port}
for proxy_obj in cluster_obj.proxyinstance_set.all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,23 @@ def RedisClusterSwitchAtomJob(root_id, data, act_kwargs: ActKwargs, sync_params:
kwargs=asdict(swith_act),
)

# 检查Proxy后端一致性
# 检查Proxy后端一致性; 精简一下传入参数,对于超大集群太多了
check_act = deepcopy(act_kwargs)
if act_kwargs.cluster["cluster_type"] in [
ClusterType.TwemproxyTendisSSDInstance,
ClusterType.TendisTwemproxyRedisInstance,
]:
act_kwargs.get_redis_payload_func = RedisActPayload.redis_twemproxy_backends_4_scene.__name__
check_act.cluster = {
"bk_biz_id": act_kwargs.cluster["bk_biz_id"],
"cluster_id": act_kwargs.cluster["cluster_id"],
"cluster_type": act_kwargs.cluster["cluster_type"],
"immute_domain": act_kwargs.cluster["immute_domain"],
}
check_act.get_redis_payload_func = RedisActPayload.redis_twemproxy_backends_4_scene.__name__
sub_pipeline.add_act(
act_name=_("{}-检查切换状态").format(exec_ip),
act_component_code=ExecuteDBActuatorScriptComponent.code,
kwargs=asdict(act_kwargs),
kwargs=asdict(check_act),
)

# 刷新DNS 主从版本需要
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ def precheck_for_compelete_replace(self):
for cluster_replacement in self.data["infos"]:
for cluster_id in cluster_replacement["cluster_ids"]:
try:
cluster = Cluster.objects.get(id=cluster_id, bk_biz_id=self.data["bk_biz_id"])
cluster = Cluster.objects.prefetch_related(
"proxyinstance_set",
"storageinstance_set",
"proxyinstance_set__machine",
"storageinstance_set__machine",
).get(id=cluster_id, bk_biz_id=self.data["bk_biz_id"])
except Cluster.DoesNotExist as e:
raise Exception("redis cluster does not exist,{}", e)
# check proxy
Expand Down

0 comments on commit ccff2fe

Please sign in to comment.