Skip to content

Commit

Permalink
fix(backend): 修复集群列表域名不全问题 TencentBlueKing#7343
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud committed Oct 15, 2024
1 parent 6ea6a27 commit c65cbbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions dbm-ui/backend/db_services/dbbase/resources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ def _filter_cluster_hook(
Prefetch("clusterentry_set", to_attr="entries"),
"tag_set",
)
cluster_ids = list(cluster_queryset.values_list("id", flat=True))
# 由于对 queryset 切片工作方式的模糊性,这里的values可能会获得非预期的排序,所以不要在切片后用values
# cluster_ids = list(cluster_queryset.values_list("id", flat=True))
cluster_ids = [c.id for c in cluster_queryset]

# 获取集群与访问入口的映射
cluster_entry_map = ClusterEntry.get_cluster_entry_map(cluster_ids)
Expand Down Expand Up @@ -889,8 +891,9 @@ def _get_machine_extra_info(cls, machine: Machine) -> dict:
# 获取machine关联的集群信息,目前一个实例只关联一个集群
related_clusters_map: Dict[int, List[Dict]] = {}
for inst in [*list(machine.storageinstance_set.all()), *list(machine.proxyinstance_set.all())]:
cluster = inst.cluster.all()[0]
related_clusters_map[cluster.id] = cluster.to_dict()
cluster = inst.cluster.first()
if cluster:
related_clusters_map[cluster.id] = cluster.to_dict()

return {
"instance_role": instance_role,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def validate(self, attrs):
for info in attrs["infos"]:
# 校验当前版本不能和目标版本一致
if info["target_version"] in info["current_versions"]:
raise serializers.ValidationError(_("当前版本不能和目标版本{}一致").fromat(info["current_versions"]))
raise serializers.ValidationError(_("当前版本不能和目标版本{}一致").format(info["current_versions"]))

return attrs

Expand Down

0 comments on commit c65cbbf

Please sign in to comment.