From 92363490b725cca345298a9f10613257a7500c9a Mon Sep 17 00:00:00 2001 From: Tao feng Date: Mon, 14 May 2018 10:35:39 +0200 Subject: [PATCH] [AIRFLOW-2376] Fix no hive section error Closes #3343 from feng-tao/airflow-2376 --- airflow/bin/cli.py | 9 ++++++++- airflow/utils/configuration.py | 15 +++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py index 1615e76fba2f9..931849c12cf2f 100644 --- a/airflow/bin/cli.py +++ b/airflow/bin/cli.py @@ -19,6 +19,7 @@ # under the License. from __future__ import print_function +from backports.configparser import NoSectionError import logging import os @@ -438,7 +439,13 @@ def run(args, dag=None): # core.sql_alchemy_pool_recycle for section, config in conf_dict.items(): for option, value in config.items(): - conf.set(section, option, value) + try: + conf.set(section, option, value) + except NoSectionError: + log.error('Section {section} Option {option} ' + 'does not exist in the config!'.format(section=section, + option=option)) + settings.configure_vars() # IMPORTANT, have to use the NullPool, otherwise, each "run" command may leave diff --git a/airflow/utils/configuration.py b/airflow/utils/configuration.py index 09844282a8858..18a338c23f6ff 100644 --- a/airflow/utils/configuration.py +++ b/airflow/utils/configuration.py @@ -7,9 +7,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -26,11 +26,6 @@ from airflow import configuration as conf -COPY_SECTIONS = [ - 'core', 'smtp', 'scheduler', 'celery', 'webserver', 'hive' -] - - def tmp_configuration_copy(): """ Returns a path for a temporary file including a full copy of the configuration @@ -40,11 +35,7 @@ def tmp_configuration_copy(): cfg_dict = conf.as_dict(display_sensitive=True) temp_fd, cfg_path = mkstemp() - cfg_subset = dict() - for section in COPY_SECTIONS: - cfg_subset[section] = cfg_dict.get(section, {}) - with os.fdopen(temp_fd, 'w') as temp_file: - json.dump(cfg_subset, temp_file) + json.dump(cfg_dict, temp_file) return cfg_path