update: yarn_client.py add parsed html fallback

This commit is contained in:
Claude
2026-06-30 11:02:53 +08:00
parent 32ee167b59
commit f840791999
+15 -10
View File
@@ -239,16 +239,21 @@ def _fetch_logs_via_am_container(application_id: str, config: YarnClientConfig)
# Fallback path: Knox / wrapped YARN serves an HTML directory listing for # Fallback path: Knox / wrapped YARN serves an HTML directory listing for
# every URL on the NodeManager log endpoint. Parse it and fetch each file. # every URL on the NodeManager log endpoint. Parse it and fetch each file.
resp = _request("GET", am_container_logs, timeout=60.0, verify=verify, auth=auth) orig_resp_text = resp.text
if resp.status_code < 400: try:
parts: list[str] = [] resp = _request("GET", am_container_logs, timeout=60.0, verify=verify, auth=auth)
for filename in _parse_log_listing_html(resp.text): if resp.status_code < 400:
file_url = f"{am_container_logs}/{filename}" parts: list[str] = []
file_resp = _request("GET", file_url, timeout=60.0, verify=verify, auth=auth) for filename in _parse_log_listing_html(resp.text):
if file_resp.status_code < 400 and not _looks_like_html(file_resp.text): file_url = f"{am_container_logs}/{filename}"
parts.append(f"=== {filename} ===\n{file_resp.text}") file_resp = _request("GET", file_url, timeout=60.0, verify=verify, auth=auth)
if parts: if file_resp.status_code < 400 and not _looks_like_html(file_resp.text):
return "\n\n".join(parts) parts.append(f"=== {filename} ===\n{file_resp.text}")
if parts:
return "\n\n".join(parts)
except Exception as ex:
logger.warning(f"Parse html error: {ex}")
return orig_resp_text
raise _logs_unavailable_error(application_id) raise _logs_unavailable_error(application_id)