Skip to content

Commit

Permalink
Bind log server on worker to IPv6 address (apache#24755)
Browse files Browse the repository at this point in the history
  • Loading branch information
zartstrom committed Jul 5, 2022
1 parent d969473 commit d469bc4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 15 additions & 7 deletions airflow/utils/serve_logs.py
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}"),
GunicornOption("workers", 2),
]
StandaloneGunicornApplication(wsgi_app, options).run()


Expand Down
1 change: 1 addition & 0 deletions newsfragments/24755.improvement.rst
@@ -0,0 +1 @@
Log server on worker binds IPv6 interface.

0 comments on commit d469bc4

Please sign in to comment.