diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py index dbab8b38d89e9..14928bbd4802b 100644 --- a/airflow/bin/cli.py +++ b/airflow/bin/cli.py @@ -488,6 +488,24 @@ 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 @@ -510,18 +528,15 @@ def run(args, dag=None): try: conf.set(section, option, value) except NoSectionError: - optional_sections = [ - 'atlas', 'mesos', 'elasticsearch', 'kubernetes', - 'lineage', 'hive' - ] - if section in optional_sections: - log.debug('Section {section} Option {option} ' - 'does not exist in the config!'.format(section=section, - option=option)) + 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('Section {section} Option {option} ' - 'does not exist in the config!'.format(section=section, - option=option)) + log.error(no_section_msg) settings.configure_vars()