Skip to content

Commit df8367f

Browse files
authored
Merge pull request #39 from moises-ai/chore/json-logging-1-6
chore(deps): drop the missing-client access-log workaround now that json-logging 1.6 fixes it
2 parents 982d1b4 + 6a1e406 commit df8367f

6 files changed

Lines changed: 36 additions & 130 deletions

File tree

‎maestro_worker_python/request_logging.py‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎maestro_worker_python/serve.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from .health import get_health_metadata
2222
from .kill_process import kill_child_processes, terminate_current_process
2323
from .load_worker import load_worker
24-
from .request_logging import register_client_safe_request_extractor
2524
from .response import FatalWorkerError, ValidationError, WorkerResponse
2625

2726

@@ -88,7 +87,6 @@ async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
8887
logging.basicConfig(level=settings.log_level.upper())
8988

9089
if settings.enable_json_logging:
91-
register_client_safe_request_extractor()
9290
# json_logging pins its own logger to DEBUG at import, and init logs at DEBUG before
9391
# the root handler is JSON, leaking a plain-text line that Cloud Logging files as ERROR.
9492
logging.getLogger("json_logging").setLevel(logging.INFO)

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT"
88
authors = [{ name = "Moises.ai" }]
99
dependencies = [
1010
"fastapi>=0.139.2,<0.140",
11-
"json-logging>=1.3,<2",
11+
"json-logging>=1.6,<2",
1212
"nvidia-ml-py>=12.535,<14",
1313
"psutil>=6.0.0,<7.1",
1414
"pydantic>=2.9,<3",

‎tests/test_request_logging.py‎

Lines changed: 0 additions & 87 deletions
This file was deleted.

‎tests/test_serve.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,34 @@ def test_json_logging_keeps_reporting_its_own_warnings(tmp_path):
390390
assert result.returncode == 0, result.stderr
391391
records = [json.loads(line) for line in _log_lines(result) if line.startswith("{")]
392392
assert any(r["msg"] == "probe" and r["level"] == "WARNING" for r in records), records
393+
394+
395+
SERVE_A_REQUEST_WITHOUT_A_PEER = """
396+
import asyncio, sys
397+
398+
scope = {
399+
"type": "http", "asgi": {"version": "3.0"}, "http_version": "1.1", "scheme": "http",
400+
"method": "GET", "path": "/health", "raw_path": b"/health", "query_string": b"",
401+
"root_path": "", "headers": [], "client": None, "server": ("testserver", 80),
402+
}
403+
404+
async def receive():
405+
return {"type": "http.request", "body": b"", "more_body": False}
406+
407+
messages = []
408+
409+
async def send(message):
410+
messages.append(message)
411+
412+
asyncio.run(serve.app(scope, receive, send))
413+
print([m["status"] for m in messages if m["type"] == "http.response.start"], file=sys.stderr)
414+
"""
415+
416+
417+
def test_json_logging_serves_a_request_without_a_peer_cleanly(tmp_path):
418+
# A kubelet resetting a timed-out readiness probe leaves Request.client as None.
419+
result = _start_with_json_logging(tmp_path, SERVE_A_REQUEST_WITHOUT_A_PEER)
420+
421+
assert result.returncode == 0, result.stderr
422+
assert "[200]" in result.stderr
423+
assert "Logging error" not in result.stderr, result.stderr

‎uv.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)