You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/12/18 06:02:01 UTC

[jira] [Commented] (AIRFLOW-2824) Disable loading of default connections via airflow config

    [ https://issues.apache.org/jira/browse/AIRFLOW-2824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16723728#comment-16723728 ] 

ASF GitHub Bot commented on AIRFLOW-2824:
-----------------------------------------

stale[bot] closed pull request #3796: [AIRFLOW-2824] - Add config to disable default conn creation
URL: https://github.com/apache/incubator-airflow/pull/3796
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/config_templates/default_airflow.cfg b/airflow/config_templates/default_airflow.cfg
index 18c486cb1e..bb1e1c8665 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -122,6 +122,10 @@ non_pooled_task_slot_count = 128
 # The maximum number of active DAG runs per DAG
 max_active_runs_per_dag = 16
 
+# Whether to load the default connections during the CLI command
+# `airflow initdb`.
+load_default_conns = True
+
 # Whether to load the examples that ship with Airflow. It's good to
 # get started, but you probably want to set this to False in a production
 # environment
diff --git a/airflow/utils/db.py b/airflow/utils/db.py
index b57b8cf92b..9c9fd6bcad 100644
--- a/airflow/utils/db.py
+++ b/airflow/utils/db.py
@@ -27,6 +27,7 @@
 import os
 import contextlib
 
+from airflow import configuration
 from airflow import settings
 from airflow.utils.log.logging_mixin import LoggingMixin
 
@@ -85,11 +86,8 @@ def merge_conn(conn, session=None):
         session.commit()
 
 
-def initdb(rbac=False):
-    session = settings.Session()
-
+def load_default_conns():
     from airflow import models
-    upgradedb()
 
     merge_conn(
         models.Connection(
@@ -286,6 +284,16 @@ def initdb(rbac=False):
             conn_id='cassandra_default', conn_type='cassandra',
             host='cassandra', port=9042))
 
+
+def initdb(rbac=False):
+    session = settings.Session()
+
+    from airflow import models
+    upgradedb()
+
+    if configuration.conf.getboolean('core', 'LOAD_DEFAULT_CONNS'):
+        load_default_conns()
+
     # Known event types
     KET = models.KnownEventType
     if not session.query(KET).filter(KET.know_event_type == 'Holiday').first():


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Disable loading of default connections via airflow config
> ---------------------------------------------------------
>
>                 Key: AIRFLOW-2824
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2824
>             Project: Apache Airflow
>          Issue Type: Wish
>            Reporter: Felix Uellendall
>            Assignee: Andy Cooper
>            Priority: Major
>
> I would love to have a variable I can set in the airflow.cfg, like the DAG examples have, to not load the default connections.
> Either by using {{load_examples}} that is already [there|https://github.com/apache/incubator-airflow/blob/dfa7b26ddaca80ee8fd9915ee9f6eac50fac77f6/airflow/config_templates/default_airflow.cfg#L128] for loading dag examples or by a new one like {{load_default_connections}} to check if the user wants to have it or not.
> The implementation of the default connections starts [here|https://github.com/apache/incubator-airflow/blob/9e1d8ee837ea2c23e828d070b6a72a6331d98602/airflow/utils/db.py#L94]
> Let me know what you guys think of it, pls. :)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)