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
# 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)
if resp.status_code < 400:
parts: list[str] = []
for filename in _parse_log_listing_html(resp.text):
file_url = f"{am_container_logs}/{filename}"
file_resp = _request("GET", file_url, timeout=60.0, verify=verify, auth=auth)
if file_resp.status_code < 400 and not _looks_like_html(file_resp.text):
parts.append(f"=== {filename} ===\n{file_resp.text}")
if parts:
return "\n\n".join(parts)
orig_resp_text = resp.text
try:
resp = _request("GET", am_container_logs, timeout=60.0, verify=verify, auth=auth)
if resp.status_code < 400:
parts: list[str] = []
for filename in _parse_log_listing_html(resp.text):
file_url = f"{am_container_logs}/{filename}"
file_resp = _request("GET", file_url, timeout=60.0, verify=verify, auth=auth)
if file_resp.status_code < 400 and not _looks_like_html(file_resp.text):
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)