Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-6271] Printing log files read during load_test_config #6842

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from collections import OrderedDict
# Ignored Mypy on configparser because it thinks the configparser module has no _UNSET attribute
from configparser import _UNSET, ConfigParser, NoOptionError, NoSectionError # type: ignore
from typing import Dict
from typing import Dict, Tuple

from cryptography.fernet import Fernet
from zope.deprecation import deprecated
Expand Down Expand Up @@ -81,15 +81,15 @@ def run_command(command):
return output


def _read_default_config_file(file_name: str) -> str:
def _read_default_config_file(file_name: str) -> Tuple[str, str]:
templates_dir = os.path.join(os.path.dirname(__file__), 'config_templates')
file_path = os.path.join(templates_dir, file_name)
with open(file_path, encoding='utf-8') as file:
return file.read()
with open(file_path, encoding='utf-8') as config_file:
return config_file.read(), file_path


DEFAULT_CONFIG = _read_default_config_file('default_airflow.cfg')
TEST_CONFIG = _read_default_config_file('default_test.cfg')
DEFAULT_CONFIG, DEFAULT_CONFIG_FILE_PATH = _read_default_config_file('default_airflow.cfg')
TEST_CONFIG, TEST_CONFIG_FILE_PATH = _read_default_config_file('default_test.cfg')


class AirflowConfigParser(ConfigParser):
Expand Down Expand Up @@ -430,10 +430,13 @@ def load_test_config(self):
Note: this is not reversible.
"""
# override any custom settings with defaults
log.info("Overriding settings with defaults from %s", DEFAULT_CONFIG_FILE_PATH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be debug -- it's a bit too noisy and not useful to see this all the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nm, this is load_test_config only :)

self.read_string(parameterized_config(DEFAULT_CONFIG))
# then read test config
log.info("Reading default test configuration from %s", TEST_CONFIG_FILE_PATH)
self.read_string(parameterized_config(TEST_CONFIG))
# then read any "custom" test settings
log.info("Reading test configuration from %s", TEST_CONFIG_FILE)
self.read(TEST_CONFIG_FILE)

def _warn_deprecate(self, section, key, deprecated_name):
Expand Down Expand Up @@ -565,7 +568,7 @@ def get_airflow_test_config(airflow_home):

if not os.path.isfile(WEBSERVER_CONFIG):
log.info('Creating new FAB webserver config file in: %s', WEBSERVER_CONFIG)
DEFAULT_WEBSERVER_CONFIG = _read_default_config_file('default_webserver_config.py')
DEFAULT_WEBSERVER_CONFIG, _ = _read_default_config_file('default_webserver_config.py')
with open(WEBSERVER_CONFIG, 'w') as file:
file.write(DEFAULT_WEBSERVER_CONFIG)

Expand Down