feat(yarn_client): SSL/TLS config for YARN REST connections

Add per-Connection ssl_verify / ssl_ca_bundle plus global defaults so
CDH 5 / on-prem clusters with self-signed certs or custom CA bundles can
be queried without patching code.

- Connection gets ssl_verify (bool|None) and ssl_ca_bundle (str|None)
- Settings gets ssl_verify_default and ssl_ca_bundle_default
- New YarnClientConfig dataclass carries the resolved verify= value
- _request passes verify= through to httpx.request
- All public yarn_client functions now take YarnClientConfig instead of
  a bare yarn_rm_url string; tool call sites resolve the Connection
- SaveConnectionRequest exposes the two new fields

Tests cover per-connection CA bundle, per-connection verify=False,
global default fallback, and connection-not-found error.
This commit is contained in:
Claude
2026-06-26 13:50:30 +08:00
parent 5566d55a7c
commit ad557b5984
16 changed files with 362 additions and 87 deletions
+31 -3
View File
@@ -2,13 +2,26 @@
from datetime import datetime
from unittest.mock import patch
import pytest
from spark_executor.core import connection_store
from spark_executor.core.job_store import JobStore
from spark_executor.models import Job
from spark_executor.models import Connection, Job
from spark_executor.tools import logs
from spark_executor.tools import connections
def _fresh_stores():
store = connection_store.ConnectionStore()
connection_store.store = store
connections.store = store
logs.conn_store = store
logs.store = JobStore()
def _seed(job_id="abc", app_id="application_1"):
logs.store = JobStore()
_fresh_stores()
logs.conn_store.save(Connection(name="prod", master="yarn", yarn_rm_url="http://rm:8088"))
logs.store.put(
Job(
job_id=job_id,
@@ -43,6 +56,21 @@ def test_get_job_logs_respects_custom_tail_chars():
def test_get_job_logs_raises_for_unknown_job():
_seed()
import pytest
with pytest.raises(KeyError):
logs.get_job_logs("missing")
def test_get_job_logs_raises_when_connection_missing():
_fresh_stores()
logs.store.put(
Job(
job_id="abc",
application_id="application_1",
script_path="/tmp/j.py",
queue="default",
submit_time=datetime(2026, 6, 24),
connection="missing",
)
)
with pytest.raises(KeyError, match="Connection not found"):
logs.get_job_logs("abc")