Skip to content

Commit

Permalink
[AIRFLOW-2376] Fix no hive section error
Browse files Browse the repository at this point in the history
Closes apache#3343 from feng-tao/airflow-2376
  • Loading branch information
Tao feng authored and Fokko Driesprong committed May 14, 2018
1 parent 648e1e6 commit 9236349
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
9 changes: 8 additions & 1 deletion airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# under the License.

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

import os
Expand Down Expand Up @@ -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
Expand Down
15 changes: 3 additions & 12 deletions airflow/utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 9236349

Please sign in to comment.