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/08/04 16:41:00 UTC

[jira] [Commented] (AIRFLOW-1749) AirflowConfigParser fails to override has_option from ConfigParser, causing broken LDAP config

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

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

ashb closed pull request #2722: [AIRFLOW-1749] Fix has_option to consider environment and cmd overrides
URL: https://github.com/apache/incubator-airflow/pull/2722
 
 
   

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/configuration.py b/airflow/configuration.py
index ff81d9827b..adefb3fc20 100644
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -175,10 +175,10 @@ def _get_cmd_option(self, section, key):
         # if this is a valid command key...
         if (section, key) in AirflowConfigParser.as_command_stdout:
             # if the original key is present, return it no matter what
-            if self.has_option(section, key):
+            if ConfigParser.has_option(self, section, key):
                 return ConfigParser.get(self, section, key)
             # otherwise, execute the fallback key
-            elif self.has_option(section, fallback_key):
+            elif ConfigParser.has_option(self, section, fallback_key):
                 command = self.get(section, fallback_key)
                 return run_command(command)
 
@@ -192,7 +192,7 @@ def get(self, section, key, **kwargs):
             return option
 
         # ...then the config file
-        if self.has_option(section, key):
+        if ConfigParser.has_option(self, section, key)
             return expand_env_var(
                 ConfigParser.get(self, section, key, **kwargs))
 
@@ -229,6 +229,11 @@ def getint(self, section, key):
     def getfloat(self, section, key):
         return float(self.get(section, key))
 
+    def has_option(self, section, key):
+        return ((self._get_env_var_option(section, key) is not None) or
+               ConfigParser.has_option(self, section, key) or
+               (self._get_cmd_option(section, key) is not None))
+
     def read(self, filenames):
         ConfigParser.read(self, filenames)
         self._validate()


 

----------------------------------------------------------------
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


> AirflowConfigParser fails to override has_option from ConfigParser, causing broken LDAP config
> ----------------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-1749
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1749
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: configuration
>    Affects Versions: Airflow 2.0, Airflow 1.8
>         Environment: Ubuntu 16.04
>            Reporter: Nick McNutt
>            Priority: Minor
>              Labels: easyfix
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> In configuration.py, class {{AirflowConfigParser}} fails to override {{has_option}} from {{ConfigParser}}.  This breaks the following in ldap_auth.py:
> {{if configuration.has_option("ldap", "search_scope"):
>             search_scope = SUBTREE if configuration.get("ldap", "search_scope") == "SUBTREE" else LEVEL}}
> This code fails to consider whether any environment variable (e.g., {{AIRFLOW__LDAP__SEARCH_SCOPE}}) or command override's are set, meaning that LDAP configuration cannot be entirely set up through environment variables.



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