diff --git a/airflow/config_templates/config.yml b/airflow/config_templates/config.yml index 2170f8f126821..f5d80e3712c87 100644 --- a/airflow/config_templates/config.yml +++ b/airflow/config_templates/config.yml @@ -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 diff --git a/airflow/config_templates/default_airflow.cfg b/airflow/config_templates/default_airflow.cfg index 0ac0c77d5bcee..9d18acee0a13c 100644 --- a/airflow/config_templates/default_airflow.cfg +++ b/airflow/config_templates/default_airflow.cfg @@ -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 diff --git a/airflow/config_templates/default_test.cfg b/airflow/config_templates/default_test.cfg index 932754a4014a4..a838c3fac6967 100644 --- a/airflow/config_templates/default_test.cfg +++ b/airflow/config_templates/default_test.cfg @@ -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 diff --git a/airflow/utils/db.py b/airflow/utils/db.py index c6e7cd4262b90..4568b50cc8a4c 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -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 diff --git a/scripts/ci/in_container/airflow_ci.cfg b/scripts/ci/in_container/airflow_ci.cfg index fc89615ba8be1..87df5167bb3b8 100644 --- a/scripts/ci/in_container/airflow_ci.cfg +++ b/scripts/ci/in_container/airflow_ci.cfg @@ -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 = diff --git a/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml b/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml index 5bc21dbb6979b..722150371be44 100644 --- a/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml +++ b/scripts/ci/in_container/kubernetes/app/templates/configmaps.template.yaml @@ -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 diff --git a/scripts/perf/sql_queries.py b/scripts/perf/sql_queries.py index 5d3dad74a25d2..344203f37e8b7 100644 --- a/scripts/perf/sql_queries.py +++ b/scripts/perf/sql_queries.py @@ -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 diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 7f1f1d2e30111..f8e64405c7d3b 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -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'))