apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
36.49k stars 14.13k forks source link

Running `db.resetdb()` (e.g. in test suite) modifies `logging.root.level` #42432

Open Kache opened 4 days ago

Kache commented 4 days ago

Apache Airflow version

Other Airflow 2 version (please specify below)

If "Other Airflow 2 version" selected, which one?

2.8.0

What happened?

Running airflow.utils.db.resetdb() (e.g. in test suite) sets logging.root.level = Logging.WARNING

It appears to apply the logging config at airflow/alembic.ini

What you think should happen instead?

resetdb() as a framework util function for clearing db state, should not modify application root logger config

How to reproduce

import logging

print(f"{logging.root.level=}")

logging.root.setLevel(logging.INFO)
print(f"{logging.root.level=}")

import airflow.utils.db
airflow.utils.db.resetdb()

print(f"{logging.root.level=}")
mkdir test_airflow_logging
cd test_airflow_logging
python -m venv .venv
. .venv/bin/activate
pip install "apache-airflow==2.10.1" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.10.1/constraints-3.11.txt"
export AIRFLOW_HOME=$(PWD)
python logging_test.py

Outputs:

logging.root.level=30
logging.root.level=20
[2024-09-23T22:36:21.856-0700] {db.py:1702} INFO - Dropping tables that exist
[2024-09-23T22:36:22.463-0700] {migration.py:215} INFO - Context impl SQLiteImpl.
[2024-09-23T22:36:22.463-0700] {migration.py:218} INFO - Will assume non-transactional DDL.
[2024-09-23T22:36:22.464-0700] {migration.py:215} INFO - Context impl SQLiteImpl.
[2024-09-23T22:36:22.464-0700] {migration.py:218} INFO - Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running stamp_revision  -> 22ed7efa9da2
WARNI [airflow.models.crypto] empty cryptography key - values will not be stored encrypted.
logging.root.level=30

Operating System

Darwin COMPNAME 23.6.0 Darwin Kernel Version 23.6.0: Wed Jul 31 20:49:39 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T6000 arm64

Versions of Apache Airflow Providers

bare/vanilla Airflow install, see repro

Deployment

Virtualenv installation

Deployment details

repro does not use deployment

Anything else?

No response

Are you willing to submit PR?

Code of Conduct

harjeevanmaan commented 4 days ago

Working on it.