From 56cc94e1f1290d977eec26a0bb5577bd61005801 Mon Sep 17 00:00:00 2001 From: Niko Oliveira Date: Wed, 27 Aug 2025 11:07:12 -0700 Subject: [PATCH 1/2] Configure logging for Triggerer This will ensure logging configuration such as colored_console_log are respected by the Triggerer processes. --- airflow-core/src/airflow/jobs/triggerer_job_runner.py | 4 ++++ airflow-core/tests/unit/jobs/test_triggerer_job.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/airflow-core/src/airflow/jobs/triggerer_job_runner.py b/airflow-core/src/airflow/jobs/triggerer_job_runner.py index d4d49e50f9f51..08ec17fbf8cb9 100644 --- a/airflow-core/src/airflow/jobs/triggerer_job_runner.py +++ b/airflow-core/src/airflow/jobs/triggerer_job_runner.py @@ -710,6 +710,10 @@ def _process_log_messages_from_subprocess(self) -> Generator[None, bytes | bytea import msgspec from structlog.stdlib import NAME_TO_LEVEL + from airflow.sdk.log import configure_logging + + configure_logging() + fallback_log = structlog.get_logger(logger_name=__name__) from airflow.sdk.log import logging_processors diff --git a/airflow-core/tests/unit/jobs/test_triggerer_job.py b/airflow-core/tests/unit/jobs/test_triggerer_job.py index f0946f91ebdd5..f0cf306a11326 100644 --- a/airflow-core/tests/unit/jobs/test_triggerer_job.py +++ b/airflow-core/tests/unit/jobs/test_triggerer_job.py @@ -1145,3 +1145,14 @@ def test_update_triggers_prevents_duplicate_creation_queue_entries_with_multiple trigger_ids = {trigger.id for trigger in supervisor.creating_triggers} assert trigger_orm1.id in trigger_ids assert trigger_orm2.id in trigger_ids + + +@patch("airflow.sdk.log.configure_logging") +def test_process_log_messages_configures_logging(mock_configure_logging, supervisor_builder): + supervisor = supervisor_builder() + + # Create the generator (this triggers the configuration reading) + log_processor_gen = supervisor._process_log_messages_from_subprocess() + next(log_processor_gen) # Initialize the generator + + assert mock_configure_logging.call_count == 1 From 696c11c178b003074a01b2344a0806c00faba08b Mon Sep 17 00:00:00 2001 From: Niko Oliveira Date: Thu, 28 Aug 2025 09:47:16 -0700 Subject: [PATCH 2/2] PR feedback: Remove unit test --- airflow-core/tests/unit/jobs/test_triggerer_job.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/airflow-core/tests/unit/jobs/test_triggerer_job.py b/airflow-core/tests/unit/jobs/test_triggerer_job.py index f0cf306a11326..f0946f91ebdd5 100644 --- a/airflow-core/tests/unit/jobs/test_triggerer_job.py +++ b/airflow-core/tests/unit/jobs/test_triggerer_job.py @@ -1145,14 +1145,3 @@ def test_update_triggers_prevents_duplicate_creation_queue_entries_with_multiple trigger_ids = {trigger.id for trigger in supervisor.creating_triggers} assert trigger_orm1.id in trigger_ids assert trigger_orm2.id in trigger_ids - - -@patch("airflow.sdk.log.configure_logging") -def test_process_log_messages_configures_logging(mock_configure_logging, supervisor_builder): - supervisor = supervisor_builder() - - # Create the generator (this triggers the configuration reading) - log_processor_gen = supervisor._process_log_messages_from_subprocess() - next(log_processor_gen) # Initialize the generator - - assert mock_configure_logging.call_count == 1