Skip to content

Commit

Permalink
sprintfix: 修复使用 Redis 缓存场景下任务历史业务列表为空的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon committed Nov 16, 2023
1 parent 440abea commit 0c477a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions apps/backend/components/collections/agent_new/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
12 changes: 10 additions & 2 deletions apps/node_man/handlers/cmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "资源池"}
Expand Down

0 comments on commit 0c477a2

Please sign in to comment.