diff --git a/spark_executor/core/yarn_client.py b/spark_executor/core/yarn_client.py index 391084d..53ff388 100644 --- a/spark_executor/core/yarn_client.py +++ b/spark_executor/core/yarn_client.py @@ -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)