diff --git a/apps/backend/components/collections/agent_new/install.py b/apps/backend/components/collections/agent_new/install.py index de3ba9f72..1f8dc2bdb 100644 --- a/apps/backend/components/collections/agent_new/install.py +++ b/apps/backend/components/collections/agent_new/install.py @@ -703,8 +703,8 @@ def handle_report_data(self, host: models.Host, sub_inst_id: int, success_callba if status == "FAILED": error_log = log logger.warning( - f"[app_core_remote:handle_report_data:scripts_error] install failed: " - f"sub_inst_id -> {sub_inst_id}, labels -> {labels}, log -> {error_log}" + f"[app_core_remote:handle_report_data:scripts_error] install failed: sub_inst_id -> {sub_inst_id}, " + f"ip -> {host.inner_ip or host.inner_ipv6}, labels -> {labels}, log -> {error_log}" ) metrics.app_core_remote_install_exceptions_total.labels(**labels).inc() is_finished = True @@ -744,7 +744,8 @@ def handle_report_data(self, host: models.Host, sub_inst_id: int, success_callba healthz_result_dict = {"is_parseable": False, "log": data["log"]} logger.warning( f"[app_core_remote:handle_report_data:scripts_error] healthz decode failed: " - f"sub_inst_id -> {sub_inst_id}, labels -> {labels}, result -> {healthz_result_dict}" + f"sub_inst_id -> {sub_inst_id}, ip -> {host.inner_ip or host.inner_ipv6}, labels -> {labels}, " + f"result -> {healthz_result_dict}" ) metrics.app_core_remote_install_exceptions_total.labels(**labels).inc() diff --git a/apps/node_man/handlers/cmdb.py b/apps/node_man/handlers/cmdb.py index db08c6321..06c7d7b0c 100644 --- a/apps/node_man/handlers/cmdb.py +++ b/apps/node_man/handlers/cmdb.py @@ -91,11 +91,19 @@ def cmdb_or_cache_biz(username: str): return {"info": []} @classmethod - def biz_id_name_without_permission(cls, username=None): + def biz_id_name_without_permission(cls, username=None) -> Dict[int, str]: biz_cache = cache.get("biz_id_name" + BIZ_CACHE_SUFFIX) if biz_cache: - return biz_cache + biz_id_name: Dict[int, str] = {} + for bk_biz_id_str, bk_biz_name in biz_cache.items(): + try: + biz_id_name[int(bk_biz_id_str)] = bk_biz_name + except Exception: + logger.warning(f"[biz_id_name_without_permission] bk_biz_id -> {bk_biz_id_str} is not int") + biz_id_name[bk_biz_id_str] = bk_biz_name + return biz_id_name + username = username or get_request_username() all_biz = cls.cmdb_or_cache_biz(username)["info"] resource_pool_biz = {"bk_biz_id": settings.BK_CMDB_RESOURCE_POOL_BIZ_ID, "bk_biz_name": "资源池"}