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-6987] Avoid creating default connections #7629

Merged
merged 1 commit into from
Mar 16, 2020
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
11 changes: 10 additions & 1 deletion airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,22 @@
default: "16"
- name: load_examples
description: |
Whether to load the examples that ship with Airflow. It's good to
Whether to load the DAG examples that ship with Airflow. It's good to
get started, but you probably want to set this to False in a production
environment
version_added: ~
type: string
example: ~
default: "True"
- name: load_default_connections
description: |
Whether to load the default connections that ship with Airflow. It's good to
get started, but you probably want to set this to False in a production
environment
version_added: 1.10.10
type: string
example: ~
default: "True"
- name: plugins_folder
description: |
Where your Airflow plugins are stored
Expand Down
7 changes: 6 additions & 1 deletion airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,16 @@ dags_are_paused_at_creation = True
# The maximum number of active DAG runs per DAG
max_active_runs_per_dag = 16

# Whether to load the examples that ship with Airflow. It's good to
# Whether to load the DAG examples that ship with Airflow. It's good to
# get started, but you probably want to set this to False in a production
# environment
load_examples = True

# Whether to load the default connections that ship with Airflow. It's good to
# get started, but you probably want to set this to False in a production
# environment
load_default_connections = True

# Where your Airflow plugins are stored
plugins_folder = {AIRFLOW_HOME}/plugins

Expand Down
1 change: 1 addition & 0 deletions airflow/config_templates/default_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ plugins_folder = {TEST_PLUGINS_FOLDER}
executor = SequentialExecutor
sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/unittests.db
load_examples = True
load_default_connections = True
donot_pickle = True
dag_concurrency = 16
dags_are_paused_at_creation = False
Expand Down
3 changes: 2 additions & 1 deletion airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def initdb():
"""
upgradedb()

create_default_connections()
if conf.getboolean('core', 'LOAD_DEFAULT_CONNECTIONS'):
create_default_connections()

dagbag = DagBag()
# Save DAGs in the ORM
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/in_container/airflow_ci.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ executor = LocalExecutor
sql_alchemy_conn = # overridden by the startup scripts
unit_test_mode = True
load_examples = True
load_default_connections = True
donot_pickle = False
dags_are_paused_at_creation = False
default_impersonation =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data:
executor = KubernetesExecutor
parallelism = 32
load_examples = False
load_default_connections = True
plugins_folder = /root/airflow/plugins
sql_alchemy_conn = $SQL_ALCHEMY_CONN

Expand Down
1 change: 1 addition & 0 deletions scripts/perf/sql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
os.environ["AIRFLOW__CORE__DAGS_FOLDER"] = DAG_FOLDER
os.environ["AIRFLOW__DEBUG__SQLALCHEMY_STATS"] = "True"
os.environ["AIRFLOW__CORE__LOAD_EXAMPLES"] = "False"
os.environ["AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS"] = "True"

# Here we setup simpler logger to avoid any code changes in
# Airflow core code base
Expand Down
2 changes: 2 additions & 0 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def test_conf_as_dict_source(self):
cfg_dict = conf.as_dict(display_source=True)
self.assertEqual(
cfg_dict['core']['load_examples'][1], 'airflow.cfg')
self.assertEqual(
cfg_dict['core']['load_default_connections'][1], 'airflow.cfg')
self.assertEqual(
cfg_dict['testsection']['testkey'], ('< hidden >', 'env var'))

Expand Down