Skip to content

Commit

Permalink
bugfix: 修复主机类型订阅 nodes 传入信息错误导致 KeyError 的问题 (fixed #132)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon authored and zhangzhw8 committed Sep 22, 2021
1 parent 5def023 commit 04ff2b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/backend/subscription/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,12 @@ def get_host_detail(host_info_list: list, bk_biz_id: int = None):
}
}
else:
cond = {}
# 如果不满足 bk_host_id / ip & bk_cloud_id 的传入格式,此时直接返回空列表,表示查询不到任何主机
# 说明:
# 1. list_hosts_without_biz 无需业务进行全量查询,无效传参格式会匹配单业务或全业务(不传bk_biz_id)主机
# 2. 无有效 ip 在后续执行 create_host_key 获取 bk_cloud_id 也会 KeyError
# 3. 综上所述,提前返回可以减少无效执行逻辑及网络IO
return []

hosts = list_biz_hosts(bk_biz_id, cond, "list_hosts_without_biz")
bk_host_ids = []
Expand Down
2 changes: 2 additions & 0 deletions dev_log/2.1.348/crayon_202109181700.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfix:
- "修复主机类型订阅 nodes 传入信息错误导致 KeyError 的问题 (fixed #132)"

0 comments on commit 04ff2b8

Please sign in to comment.