Skip to content
Merged
Show file tree
Hide file tree
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
39 changes: 1 addition & 38 deletions airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# under the License.

from __future__ import print_function
from backports.configparser import NoSectionError
import logging

import os
Expand Down Expand Up @@ -488,24 +487,6 @@ def _run(args, dag, ti):

@cli_utils.action_logging
def run(args, dag=None):
# Optional sections won't log an error if they're missing in airflow.cfg.
OPTIONAL_AIRFLOW_CFG_SECTIONS = [
'atlas',
'celery',
'celery_broker_transport_options',
'dask',
'elasticsearch',
'github_enterprise',
'hive',
'kerberos',
'kubernetes',
'kubernetes_node_selectors',
'kubernetes_secrets',
'ldap',
'lineage',
'mesos',
]

if dag:
args.dag_id = dag.dag_id

Expand All @@ -519,25 +500,7 @@ def run(args, dag=None):
if os.path.exists(args.cfg_path):
os.remove(args.cfg_path)

# Do not log these properties since some may contain passwords.
# This may also set default values for database properties like
# core.sql_alchemy_pool_size
# core.sql_alchemy_pool_recycle
for section, config in conf_dict.items():
for option, value in config.items():
try:
conf.set(section, option, value)
except NoSectionError:
no_section_msg = (
'Section {section} Option {option} '
'does not exist in the config!'
).format(section=section, option=option)

if section in OPTIONAL_AIRFLOW_CFG_SECTIONS:
log.debug(no_section_msg)
else:
log.error(no_section_msg)

conf.conf.read_dict(conf_dict, source=args.cfg_path)
Copy link
Member

@kaxil kaxil Oct 10, 2018

Choose a reason for hiding this comment

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

Not sure on source=args.cfg_path ..

Optional argument source specifies a context-specific name of the dictionary passed. If not given, <dict> is used.

What does source=args.cfg_path do in our case?

Copy link
Member Author

Choose a reason for hiding this comment

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

If there are any errors it will display the filename as the source, instead of the default of <dict> (unlikely here, as the dict as already parsed but it's an arg the method takes so it makes sense to use it)

Copy link
Member

Choose a reason for hiding this comment

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

Cool. Makes sense

settings.configure_vars()

# IMPORTANT, have to use the NullPool, otherwise, each "run" command may leave
Expand Down
4 changes: 4 additions & 0 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ def read(self, filenames):
super(AirflowConfigParser, self).read(filenames)
self._validate()

def read_dict(self, *args, **kwargs):
super(AirflowConfigParser, self).read_dict(*args, **kwargs)
self._validate()

def has_option(self, section, option):
try:
# Using self.get() to avoid reimplementing the priority order
Expand Down