diff --git a/apps/node_man/periodic_tasks/sync_cmdb_host.py b/apps/node_man/periodic_tasks/sync_cmdb_host.py index c7f2cdb7e..5e086701c 100644 --- a/apps/node_man/periodic_tasks/sync_cmdb_host.py +++ b/apps/node_man/periodic_tasks/sync_cmdb_host.py @@ -77,7 +77,9 @@ def _list_biz_hosts(biz_id: int, start: int) -> dict: } ) # 去除内网IP为空的主机 - biz_hosts["info"] = [host for host in biz_hosts["info"] if host.get("bk_host_innerip")] + biz_hosts["info"] = [ + host for host in biz_hosts["info"] if host.get("bk_host_innerip") or host.get("bk_host_innerip_v6") + ] return biz_hosts @@ -205,10 +207,10 @@ def update_or_create_host_base(biz_id, task_id, cmdb_host_data): # 已存在的主机批量更新,不存在的主机批量创建 for host in cmdb_host_data: # 兼容内网IP为空的情况 - if not host["bk_host_innerip"]: + if not (host.get("bk_host_innerip") or host.get("bk_host_innerip_v6")): logger.info( f"[sync_cmdb_host] update_or_create_host: task_id -> {task_id}, bk_biz_id -> {biz_id}, " - f"bk_host_id -> {host['bk_host_id']} bk_host_innerip is empty" + f"bk_host_id -> {host['bk_host_id']} bk_host_innerip and bk_host_innerip_v6 is empty" ) continue diff --git a/dev_log/2.2.32/crayon_202211071651.yaml b/dev_log/2.2.32/crayon_202211071651.yaml new file mode 100644 index 000000000..1921a5154 --- /dev/null +++ b/dev_log/2.2.32/crayon_202211071651.yaml @@ -0,0 +1,3 @@ +--- +bugfix: + - "修复同步不到纯 IPv6 主机的问题 (fixed #1220)"