refactor(yarn_client): use Location header verbatim, drop urljoin

YARN's 307 Location header is always a fully-qualified absolute URL.
The previous implementation used urllib.parse.urljoin to handle the
hypothetical case of a relative Location, but that's a defensive
codepath for a scenario that does not occur in practice. Drop it:

  - Remove 'from urllib.parse import urljoin'.
  - _request_following_redirects now assigns the Location value
    straight to the next request URL.
  - Update the docstring to reflect the new contract.
  - Remove the test that exercised the relative-Location path.

Full suite 246 passed (1 fewer than the previous commit, matching the
test that was removed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-30 13:42:06 +08:00
co-authored by Claude Fable 5
parent 38ac3c33d6
commit a66991b4e3
2 changed files with 5 additions and 31 deletions
-24
View File
@@ -274,30 +274,6 @@ def test_logs_follows_redirect_chain_then_200():
]
def test_logs_relative_location_resolved_against_request_url():
"""A relative Location header (e.g. '/redirected/stdout') must be
resolved against the request URL, not treated as an absolute path."""
responses = [
_resp(404), # aggregated-logs missing
_resp(
200,
json_data={
"app": {
"amContainerLogs": "http://nm1:8042/node/containerlogs/container_1/hdfs",
}
},
),
_resp(307, headers={"Location": "/redirected/stdout"}),
_resp(200, text="resolved body"),
]
with patch(
"spark_executor.core.yarn_client.httpx.request", side_effect=responses
) as m:
out = get_application_logs("application_1", YarnClientConfig(yarn_rm_url=RM))
assert out == "resolved body"
assert m.call_args_list[3].args == ("GET", "http://nm1:8042/redirected/stdout")
def test_logs_5xx_on_aggregated_endpoint_raises_immediately():
with patch(
"spark_executor.core.yarn_client.httpx.request",