fix: ignore missing nacos catalog entries
This commit is contained in:
parent
e54bf80e5a
commit
07df198822
@ -330,6 +330,7 @@ def list_instances(namespace_id: str, service_name: str, group_name: str) -> lis
|
|||||||
|
|
||||||
|
|
||||||
def catalog_instances(namespace_id: str, service_name: str, group_name: str) -> list[dict[str, Any]]:
|
def catalog_instances(namespace_id: str, service_name: str, group_name: str) -> list[dict[str, Any]]:
|
||||||
|
try:
|
||||||
# 调用 catalog/instances 获取注册表视图。
|
# 调用 catalog/instances 获取注册表视图。
|
||||||
payload = nacos_request(
|
payload = nacos_request(
|
||||||
"GET",
|
"GET",
|
||||||
@ -343,6 +344,12 @@ def catalog_instances(namespace_id: str, service_name: str, group_name: str) ->
|
|||||||
"pageSize": str(max(NACOS_PAGE_SIZE, 200)),
|
"pageSize": str(max(NACOS_PAGE_SIZE, 200)),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
except RuntimeError as exc:
|
||||||
|
# 服务不存在时按空列表处理,不让单服务失败拖垮整块 Nacos 面板。
|
||||||
|
message = str(exc).lower()
|
||||||
|
if "is not found" in message or "service " in message and "not found" in message:
|
||||||
|
return []
|
||||||
|
raise
|
||||||
|
|
||||||
# 返回 list 字段。
|
# 返回 list 字段。
|
||||||
return list(payload.get("list") or [])
|
return list(payload.get("list") or [])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user