From a3f7c22222141eacb3e43fbcadc2cbaf310f4dbb Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 9 Mar 2026 14:34:37 +0100 Subject: [PATCH 1/2] fix(airflow): Allow overriding the logging configuration --- CHANGELOG.md | 2 + ...overriding-the-logging-configuration.patch | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch diff --git a/CHANGELOG.md b/CHANGELOG.md index d29ae1ec6..fd3443ec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ All notable changes to this project will be documented in this file. - superset: Pin setup-tools to ensure pkg_resources are installed (needed for `4.1.4` builds) ([#1428]). - ubi10-rust-builder: Add gzip dependency for the ONBUILD step ([#1436]). - airflow: Pin virtualenv to prevent hatch pulling in a version with a breaking change ([#1437]). +- airflow: Allow overriding the logging configuration in Airflow 3.1.x ([#1445]). [#1336]: https://github.com/stackabletech/docker-images/pull/1336 [#1337]: https://github.com/stackabletech/docker-images/pull/1337 @@ -124,6 +125,7 @@ All notable changes to this project will be documented in this file. [#1436]: https://github.com/stackabletech/docker-images/pull/1436 [#1437]: https://github.com/stackabletech/docker-images/pull/1437 [#1442]: https://github.com/stackabletech/docker-images/pull/1442 +[#1445]: https://github.com/stackabletech/docker-images/pull/1445 ## [25.11.0] - 2025-11-07 diff --git a/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch b/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch new file mode 100644 index 000000000..c4143cca1 --- /dev/null +++ b/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch @@ -0,0 +1,50 @@ +From e603aa6796140984b2949081a74a9b280170ffd3 Mon Sep 17 00:00:00 2001 +From: Siegfried Weber +Date: Mon, 9 Mar 2026 10:11:28 +0100 +Subject: Allow overriding the logging configuration + +--- + .../src/airflow_shared/logging/structlog.py | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/shared/logging/src/airflow_shared/logging/structlog.py b/shared/logging/src/airflow_shared/logging/structlog.py +index 2d901b8303..e192308545 100644 +--- a/shared/logging/src/airflow_shared/logging/structlog.py ++++ b/shared/logging/src/airflow_shared/logging/structlog.py +@@ -376,6 +376,18 @@ def structlog_processors( + return shared_processors, console, console + + ++def update_config( ++ config: dict, ++ updates: Mapping, ++): ++ for key, value in updates.items(): ++ if isinstance(value, Mapping): ++ config[key] = update_config(config.get(key, {}), value) ++ else: ++ config[key] = value ++ return config ++ ++ + def configure_logging( + *, + json_output: bool = False, +@@ -494,7 +506,7 @@ def configure_logging( + + import logging.config + +- config = {**stdlib_config} ++ config = {} + config.setdefault("version", 1) + config.setdefault("disable_existing_loggers", False) + config["formatters"] = {**config.get("formatters", {})} +@@ -547,6 +559,8 @@ def configure_logging( + "propagate": True, + } + ++ update_config(config, stdlib_config) ++ + logging.config.dictConfig(config) + + From cd23f7f84b76453450a103f5bc1ee870a4e2447f Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Tue, 10 Mar 2026 14:51:33 +0100 Subject: [PATCH 2/2] fix(airflow): Use the log levels defined in stdlib_config for structlog --- ...overriding-the-logging-configuration.patch | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch b/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch index c4143cca1..9e66238f2 100644 --- a/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch +++ b/airflow/stackable/patches/3.1.6/0001-Allow-overriding-the-logging-configuration.patch @@ -1,14 +1,14 @@ -From e603aa6796140984b2949081a74a9b280170ffd3 Mon Sep 17 00:00:00 2001 +From 583a680fc1c6aba63d44c53db487de35a9bf6ed5 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 9 Mar 2026 10:11:28 +0100 Subject: Allow overriding the logging configuration --- - .../src/airflow_shared/logging/structlog.py | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) + .../src/airflow_shared/logging/structlog.py | 30 ++++++++++++++++++- + 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/shared/logging/src/airflow_shared/logging/structlog.py b/shared/logging/src/airflow_shared/logging/structlog.py -index 2d901b8303..e192308545 100644 +index 2d901b8303..949db2732c 100644 --- a/shared/logging/src/airflow_shared/logging/structlog.py +++ b/shared/logging/src/airflow_shared/logging/structlog.py @@ -376,6 +376,18 @@ def structlog_processors( @@ -30,7 +30,27 @@ index 2d901b8303..e192308545 100644 def configure_logging( *, json_output: bool = False, -@@ -494,7 +506,7 @@ def configure_logging( +@@ -452,6 +464,19 @@ def configure_logging( + else: + PER_LOGGER_LEVELS[log] = loglevel + ++ # Use the log levels defined in stdlib_config for structlog ++ logger_configs = stdlib_config.get("loggers", {}) ++ logger_configs[""] = stdlib_config.get("root", {}) ++ for logger, logger_config in logger_configs.items(): ++ if "level" in logger_config: ++ loglevel = logger_config["level"] ++ if isinstance(loglevel, str): ++ try: ++ loglevel = NAME_TO_LEVEL[loglevel.lower()] ++ except KeyError: ++ raise ValueError(f"Invalid log level for logger {logger!r}: {loglevel!r}") from None ++ PER_LOGGER_LEVELS[logger] = loglevel ++ + shared_pre_chain, for_stdlib, for_structlog = structlog_processors( + json_output, + log_format=log_format, +@@ -494,7 +519,7 @@ def configure_logging( import logging.config @@ -39,10 +59,11 @@ index 2d901b8303..e192308545 100644 config.setdefault("version", 1) config.setdefault("disable_existing_loggers", False) config["formatters"] = {**config.get("formatters", {})} -@@ -547,6 +559,8 @@ def configure_logging( +@@ -547,6 +572,9 @@ def configure_logging( "propagate": True, } ++ # Merge stdlib_config into config and override existing values + update_config(config, stdlib_config) + logging.config.dictConfig(config)