using existing uvicorn configuration for dp supervisor (#52473)
Signed-off-by: Gregory Pereira <grpereir@redhat.com>
Greg Pereira committed
Aug 21, 2026 at 09:06 UTC
18aa245a99d82c5ef35281c36787accd26effd8f
2 files changed
+109
tests/entrypoints/openai/test_dp_supervisor.py
+100
@@ -86,6 +86,9 @@ def _make_unit_args(**overrides) -> argparse.Namespace:
86
"pipeline_parallel_size": 1,
87
"uvicorn_log_level": "info",
88
"shutdown_timeout": 5.0,
89
+ "disable_uvicorn_access_log": False,
90
+ "disable_access_log_for_endpoints": None,
91
+ "log_config_file": None,
92
}
93
base.update(overrides)
94
return argparse.Namespace(**base)
@@ -121,6 +124,9 @@ def _make_args(**overrides) -> argparse.Namespace:
124
pipeline_parallel_size=1,
125
uvicorn_log_level="warning",
126
shutdown_timeout=0.0,
127
+ disable_uvicorn_access_log=False,
128
+ disable_access_log_for_endpoints=None,
129
+ log_config_file=None,
130
)
131
base.update(overrides)
132
return argparse.Namespace(**base)
@@ -357,6 +363,100 @@ async def test_shutdown_if_supervisor_server_error_on_startup(
363
await supervisor.run()
364
365
366
+# ---------------------------------------------------------------------------
367
+# Access-log filtering unit tests
368
+# ---------------------------------------------------------------------------
369
+
370
+
371
+@pytest.mark.asyncio
372
+async def test_start_server_applies_access_log_filter(monkeypatch):
373
+ """get_uvicorn_log_config result is forwarded to uvicorn.Config."""
374
+ sentinel_config = {"version": 1, "loggers": {}}
375
+ captured_config: list[uvicorn.Config] = []
376
+
377
+ monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: sentinel_config)
378
+
379
+ class FakeServer:
380
+ def __init__(self, config):
381
+ captured_config.append(config)
382
+ self.started = True
383
+ self.should_exit = False
384
+
385
+ async def serve(self):
386
+ pass
387
+
388
+ monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
389
+
390
+ args = _make_unit_args(
391
+ host="127.0.0.1",
392
+ disable_access_log_for_endpoints="/health,/readyz",
393
+ )
394
+ supervisor = DPSupervisor(args)
395
+ await supervisor._start_server()
396
+
397
+ assert len(captured_config) == 1
398
+ config = captured_config[0]
399
+ assert config.log_config is sentinel_config
400
+ assert config.access_log is True
401
+
402
+
403
+@pytest.mark.asyncio
404
+async def test_start_server_disables_access_log(monkeypatch):
405
+ """disable_uvicorn_access_log=True sets access_log=False."""
406
+ captured_config: list[uvicorn.Config] = []
407
+
408
+ monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: None)
409
+
410
+ class FakeServer:
411
+ def __init__(self, config):
412
+ captured_config.append(config)
413
+ self.started = True
414
+ self.should_exit = False
415
+
416
+ async def serve(self):
417
+ pass
418
+
419
+ monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
420
+
421
+ args = _make_unit_args(
422
+ host="127.0.0.1",
423
+ disable_uvicorn_access_log=True,
424
+ )
425
+ supervisor = DPSupervisor(args)
426
+ await supervisor._start_server()
427
+
428
+ assert len(captured_config) == 1
429
+ assert captured_config[0].access_log is False
430
+
431
+
432
+@pytest.mark.asyncio
433
+async def test_start_server_no_log_config_when_no_filter(monkeypatch):
434
+ """Without filtering options, default uvicorn log_config is used."""
435
+ captured_config: list[uvicorn.Config] = []
436
+
437
+ monkeypatch.setattr(dp_sup, "get_uvicorn_log_config", lambda _args: None)
438
+
439
+ class FakeServer:
440
+ def __init__(self, config):
441
+ captured_config.append(config)
442
+ self.started = True
443
+ self.should_exit = False
444
+
445
+ async def serve(self):
446
+ pass
447
+
448
+ monkeypatch.setattr(dp_sup, "NoSignalServer", FakeServer)
449
+
450
+ args = _make_unit_args(host="127.0.0.1")
451
+ supervisor = DPSupervisor(args)
452
+ await supervisor._start_server()
453
+
454
+ assert len(captured_config) == 1
455
+ config = captured_config[0]
456
+ assert config.log_config == uvicorn.Config(app=None).log_config
457
+ assert config.access_log is True
458
+
459
+
460
# ---------------------------------------------------------------------------
461
# Lifecycle integration tests – MockVLLMServer
462
# ---------------------------------------------------------------------------
vllm/entrypoints/openai/dp_supervisor.py
+9
@@ -24,6 +24,7 @@ from fastapi import FastAPI, Response
24
25
import vllm.envs as envs
26
from vllm.entrypoints.launchers.launcher import NoSignalServer
27
+from vllm.entrypoints.launchers.utils.server_utils import get_uvicorn_log_config
28
from vllm.logger import init_logger
29
from vllm.utils.system_utils import (
30
decorate_logs,
@@ -326,16 +327,24 @@ class DPSupervisor:
327
"""
328
app = _build_dp_supervisor_app(self)
329
host = self.args.host or "0.0.0.0"
330
+
331
+ uvicorn_kwargs: dict = {}
332
+ log_config = get_uvicorn_log_config(self.args)
333
+ if log_config is not None:
334
+ uvicorn_kwargs["log_config"] = log_config
335
+
336
config = uvicorn.Config(
337
app,
338
host=host,
339
port=self.supervisor_port,
340
log_level=self.args.uvicorn_log_level,
341
+ access_log=not self.args.disable_uvicorn_access_log,
342
ssl_keyfile=self.args.ssl_keyfile,
343
ssl_certfile=self.args.ssl_certfile,
344
ssl_ca_certs=self.args.ssl_ca_certs,
345
ssl_cert_reqs=self.args.ssl_cert_reqs,
346
ssl_ciphers=self.args.ssl_ciphers,
347
+ **uvicorn_kwargs,
348
)
349
supervisor_server = NoSignalServer(config)
350
supervisor_server_task = asyncio.create_task(