Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions airflow/utils/serve_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

"""Serve logs process"""
import collections
import logging
import os

Expand Down Expand Up @@ -108,6 +109,9 @@ def serve_logs_view(filename):
return flask_app


GunicornOption = collections.namedtuple("GunicornOption", ["key", "value"])


class StandaloneGunicornApplication(gunicorn.app.base.BaseApplication):
"""
Standalone Gunicorn application/serve for usage with any WSGI-application.
Expand All @@ -120,13 +124,13 @@ class StandaloneGunicornApplication(gunicorn.app.base.BaseApplication):
"""

def __init__(self, app, options=None):
self.options = options or {}
self.options = options or []
self.application = app
super().__init__()

def load_config(self):
for key, value in self.options.items():
self.cfg.set(key.lower(), value)
for option in self.options:
self.cfg.set(option.key.lower(), option.value)

def load(self):
return self.application
Expand All @@ -138,10 +142,14 @@ def serve_logs():
wsgi_app = create_app()

worker_log_server_port = conf.getint('logging', 'WORKER_LOG_SERVER_PORT')
options = {
'bind': f"0.0.0.0:{worker_log_server_port}",
'workers': 2,
}

# Make sure to have both an IPv4 and an IPv6 interface.
# Gunicorn can bind multiple addresses, see https://docs.gunicorn.org/en/stable/settings.html#bind.
options = [
GunicornOption("bind", f"0.0.0.0:{worker_log_server_port}"),
GunicornOption("bind", f"[::]:{worker_log_server_port}"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause any problems if ipv6 isn't enabled?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it breaks the gunicorn startup with a failure. Below more details #24846 (comment)

GunicornOption("workers", 2),
]
StandaloneGunicornApplication(wsgi_app, options).run()


Expand Down
1 change: 1 addition & 0 deletions newsfragments/24755.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log server on worker binds IPv6 interface.
Comment thread
eladkal marked this conversation as resolved.