This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v3-1-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 07768b174be77f9deb0c9a0093d3c4db877f5109 Author: Ash Berlin-Taylor <[email protected]> AuthorDate: Tue Sep 16 14:05:01 2025 +0100 Simplify serve_logs IPv4/v6 binding (#55716) We were trying to be "smart" about what interface we listened on, but that isn't really needed, and passing an empty host achieves the same effect: ``` $ netstat -antlp | grep 8793 tcp 0 0 0.0.0.0:8793 0.0.0.0:* LISTEN 85699/airflow serve tcp6 0 0 :::8793 :::* LISTEN 85699/airflow serve ``` The existing approach was working fine for most people (including myself) it was working fine and listening on ipv6 and v4 wildcard interfaces as expected, but some Docker/container set ups this was not the case, and despite Dualstack saying True, listening on `::` ended up _only_ listening on IPv6, but the entry in `/etc/hosts` in the container only had an entry for the IPv4 address of the pod, which we weren't listening on, so log requests would fail. Which is all a round about way of saying "doing less works better" 😀 (We also don't need the getattr+lambda anymore, as that was to support Python <= 3.7!) Fixes #55470 (cherry picked from commit 9ff753d4fb1925c94aee3ae90d7efd0d68423111) --- airflow-core/src/airflow/utils/serve_logs/core.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/airflow-core/src/airflow/utils/serve_logs/core.py b/airflow-core/src/airflow/utils/serve_logs/core.py index 9f7543d5076..f7dcade8d5f 100644 --- a/airflow-core/src/airflow/utils/serve_logs/core.py +++ b/airflow-core/src/airflow/utils/serve_logs/core.py @@ -42,19 +42,15 @@ def serve_logs(port=None): port = port or conf.getint("logging", "WORKER_LOG_SERVER_PORT") - # If dual stack is available and IPV6_V6ONLY is not enabled on the socket - # then when IPV6 is bound to it will also bind to IPV4 automatically - if getattr(socket, "has_dualstack_ipv6", lambda: False)(): - host = "::" # ASGI uses `::` syntax for IPv6 binding instead of the `[::]` notation used in WSGI, while preserving the `[::]` format in logs + if socket.has_dualstack_ipv6(): serve_log_uri = f"http://[::]:{port}" else: - host = "0.0.0.0" - serve_log_uri = f"http://{host}:{port}" + serve_log_uri = f"http://0.0.0.0:{port}" logger.info("Starting log server on %s", serve_log_uri) # Use uvicorn directly for ASGI applications - uvicorn.run("airflow.utils.serve_logs.log_server:get_app", host=host, port=port, log_level="info") + uvicorn.run("airflow.utils.serve_logs.log_server:get_app", host="", port=port, log_level="info") # Log serving is I/O bound and has low concurrency, so single process is sufficient
