You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/07/07 20:16:44 UTC
[airflow] branch main updated: Bind log server on worker to IPv6 address (#24755) (#24846)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 2f29bfefb5 Bind log server on worker to IPv6 address (#24755) (#24846)
2f29bfefb5 is described below
commit 2f29bfefb59b0014ae9e5f641d3f6f46c4341518
Author: Philipp Hitzler <ph...@gmail.com>
AuthorDate: Thu Jul 7 22:16:36 2022 +0200
Bind log server on worker to IPv6 address (#24755) (#24846)
---
airflow/utils/serve_logs.py | 22 +++++++++++++++-------
newsfragments/24755.improvement.rst | 1 +
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/airflow/utils/serve_logs.py b/airflow/utils/serve_logs.py
index e14162178b..447cff6d90 100644
--- a/airflow/utils/serve_logs.py
+++ b/airflow/utils/serve_logs.py
@@ -16,6 +16,7 @@
# under the License.
"""Serve logs process"""
+import collections
import logging
import os
@@ -108,6 +109,9 @@ def create_app():
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.
@@ -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
@@ -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()
diff --git a/newsfragments/24755.improvement.rst b/newsfragments/24755.improvement.rst
new file mode 100644
index 0000000000..1a75c283f4
--- /dev/null
+++ b/newsfragments/24755.improvement.rst
@@ -0,0 +1 @@
+Log server on worker binds IPv6 interface.