diff --git a/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/other.py b/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/other.py index a3b90b392e..2f476b2bc9 100644 --- a/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/other.py +++ b/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/other.py @@ -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() diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/atom_jobs/redis_switch.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/atom_jobs/redis_switch.py index 720218cb32..426e12ab20 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/atom_jobs/redis_switch.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/atom_jobs/redis_switch.py @@ -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 主从版本需要 diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_cmr.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_cmr.py index 8822744d3f..f07ac1bf73 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_cmr.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_cmr.py @@ -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