Skip to content

Commit

Permalink
fix(backend): 集群访问入口目标详情数据类型一致的问题 TencentBlueKing#7760
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Nov 5, 2024
1 parent 3c3161c commit d6a6785
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions dbm-ui/backend/db_meta/models/cluster_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,29 @@ def get_cluster_entry_map(cls, cluster_ids: List[int]) -> Dict[int, Dict[str, st
@property
def detail(self):
"""入口详情"""

# 以下几类访问入口,都是指向 proxy
proxy = self.proxyinstance_set.first()
detail = {}
if self.cluster_entry_type == ClusterEntryType.CLB:
detail_obj = self.clbentrydetail_set.first()
# 补充clb域名
clb_dns = ClusterEntry.objects.filter(forward_to=self, cluster_entry_type=ClusterEntryType.CLBDNS).first()
return {**model_to_dict(detail_obj), **{"clb_domain": getattr(clb_dns, "entry", "")}} if detail_obj else {}
detail = (
{**model_to_dict(detail_obj), **{"clb_domain": getattr(clb_dns, "entry", "")}} if detail_obj else {}
)

if self.cluster_entry_type == ClusterEntryType.POLARIS:
detail_obj = self.polarisentrydetail_set.first()
return {**model_to_dict(detail_obj), **{"url": getattr(detail_obj, "url", "")}} if detail_obj else {}
detail = {**model_to_dict(detail_obj), **{"url": getattr(detail_obj, "url", "")}} if detail_obj else {}

if self.cluster_entry_type == ClusterEntryType.CLBDNS:
detail_obj = self.forward_to
return model_to_dict(detail_obj) if detail_obj else {}
detail = model_to_dict(detail_obj) if detail_obj else {}

if proxy:
detail.update({"port": proxy.port})

return {}
return detail

def __str__(self):
return "{}:{}".format(self.cluster_entry_type, self.entry)
Expand Down
2 changes: 1 addition & 1 deletion dbm-ui/backend/db_services/dbbase/resources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def query_cluster_entry_details(cls, cluster_details, **kwargs):
bk_biz_id=cluster_details["bk_biz_id"], bk_cloud_id=cluster_details["bk_cloud_id"]
).get_domain(entry.entry)
else:
target_details = entry.detail
target_details = [entry.detail]

entry_details.append(
{
Expand Down

0 comments on commit d6a6785

Please sign in to comment.