airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <>
Subject [jira] [Commented] (AIRFLOW-2127) Airflow's Alembic migrations globally disable logging
Date Sun, 25 Feb 2018 11:23:00 GMT


ASF subversion and git services commented on AIRFLOW-2127:

Commit 496d0f4372a2eead616b8074db357db2b71c28eb in incubator-airflow's branch refs/heads/master
from [~jiffyclub]
[;h=496d0f4 ]

[AIRFLOW-2127] Keep loggers during DB migrations

Python's logging.config.fileConfig function will,
by default,
disable all existing loggers when it is called.
The fileConfig
function is used with default arguments by Airflow
Alembic migrations and disables all loggers except
those from
alembic and sqlalchemy (this includes disabling
Airflow's own loggers).
This change sets the disable_existing_loggers flag
of fileConfig to
False so that it _does not_ disable any existing
loggers, allowing them
to continue working as normal.

See more in

Closes #3059 from jiffyclub/AIRFLOW-2127

> Airflow's Alembic migrations globally disable logging
> -----------------------------------------------------
>                 Key: AIRFLOW-2127
>                 URL:
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: db
>            Reporter: Matt Davis
>            Priority: Major
>             Fix For: 1.10.0
> When running Airflow's {{[upgradedb|]}},
and {{[initdb|]}} functions
logging is disabled thereafter for all but the {{sqlalchemy.engine}} and {{alembic}} loggers.
This is caused [this usage|]
of Python's {{fileConfig}} function, which by default disables all loggers that aren't part
of the supplied configuration. (See [Python 2 docs|]
and [Python 3 docs|].)
This can be fixed by adding {{disable_existing_loggers=False}} to the call of {{fileConfig}}.
> This has affected us at Clover Health because we use these database utility functions
in some of our tooling, and particularly our _tests_ of the tooling. Having all logging disabled
in the midst of our tests makes it more difficult to test our use of logging in completely
unrelated parts of our codebase.
> As an example, we were trying to use [pytest's caplog feature|],
but were unable to do so with logging globally disabled by {{fileConfig}}. Here's an example
of a test that fails with {{disable_existing_loggers=True}} (the default), but passes with
> {code}
> import logging
> import pytest
> import airflow.utils.db as af_db
> LOGGER = logging.getLogger(__name__)
> @pytest.fixture(autouse=True)
> def resetdb():
>     af_db.resetdb()
> def test_caplog(caplog):
>'LINE 1')
>     assert caplog.record_tuples
>     assert 'LINE 1' in caplog.text
> {code}
> I'll submit a pull request shortly to add {{disable_existing_loggers=False}} to Airflow's

This message was sent by Atlassian JIRA

View raw message