You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/26 04:50:22 UTC

[GitHub] [airflow] doowhtron opened a new issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

doowhtron opened a new issue #16079:
URL: https://github.com/apache/airflow/issues/16079


   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
   Don't worry if they're not all applicable; just try to include what you can :-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
   NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
   
   PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
   
   Please complete the next sections or the issue will be closed.
   These questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**:
   
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release):centos7
   - **Kernel** (e.g. `uname -a`): 3.10.0
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   
   <!-- (please include exact error messages if you can) -->
   After upgraded from 2.0.1 to 2.1.0, airflow fails with the error:
   ```
   Traceback (most recent call last):
     File "/data/apps/pyenv/versions/airflow-py381/bin/airflow", line 6, in <module>
       from airflow.__main__ import main
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/__init__.py", line 34, in <module>
       from airflow import settings
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/settings.py", line 35, in <module>
       from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf  # NOQA F401
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 1117, in <module>
       conf = initialize_config()
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 879, in initialize_config
       conf.validate()
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 204, in validate
       self._validate_config_dependencies()
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 232, in _validate_config_dependencies
       is_sqlite = "sqlite" in self.get('core', 'sql_alchemy_conn')
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 344, in get
       option = self._get_environment_variables(deprecated_key, deprecated_section, key, section)
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 410, in _get_environment_variables
       option = self._get_env_var_option(section, key)
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 314, in _get_env_var_option
       return _get_config_value_from_secret_backend(os.environ[env_var_secret_path])
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 83, in _get_config_value_from_secret_backend
       secrets_client = get_custom_secret_backend()
     File "/data/apps/pyenv/versions/3.8.1/envs/airflow-py381/lib/python3.8/site-packages/airflow/configuration.py", line 1018, in get_custom_secret_backend
       secrets_backend_cls = conf.getimport(section='secrets', key='backend')
   NameError: name 'conf' is not defined
   ```
   
   I have mask the password in airflow.cfg using the following env vars and define my own secrets backend in airflow.cfg
   ```
   export AIRFLOW__CORE__SQL_ALCHEMY_CONN_SECRET=AIRFLOW__CORE__SQL_ALCHEMY_CONN_ENC
   export AIRFLOW__CELERY__BROKER_URL_SECRET=AIRFLOW__CELERY__BROKER_URL_ENC
   export AIRFLOW__CELERY__RESULT_BACKEND_SECRET=AIRFLOW__CELERY__RESULT_BACKEND_ENC
   ```
   
   And I fixed this by move "conf.validate()": 
   
   ```configuration.py
   conf = initialize_config()
   secrets_backend_list = initialize_secrets_backends()
   conf.validate()
   ```
   
   
   **What you expected to happen**:
   
   <!-- What do you think went wrong? -->
   
   The upgradation should be compatible.
   
   **How to reproduce it**:
   <!---
   
   As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.
   
   If you are using kubernetes, please attempt to recreate the issue using minikube or kind.
   
   ## Install minikube/kind
   
   - Minikube https://minikube.sigs.k8s.io/docs/start/
   - Kind https://kind.sigs.k8s.io/docs/user/quick-start/
   
   If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action
   
   You can include images using the .md style of
   ![alt text](http://url/to/img.png)
   
   To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.
   
   --->
   
   Use a self-define secret backend
   
   **Anything else we need to know**:
   
   <!--
   
   How often does this problem occur? Once? Every time etc?
   
   Any relevant logs to include? Put them here in side a detail tag:
   <details><summary>x.log</summary> lots of stuff </details>
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] theis188 commented on issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

Posted by GitBox <gi...@apache.org>.
theis188 commented on issue #16079:
URL: https://github.com/apache/airflow/issues/16079#issuecomment-849177960


   I noticed this issue when using both a secret for sqlalchemy conn, and a custom secrets backend. It existed in Airflow 2.1.0 when using these two (sqlalchemy conn secret, and a custom secrets backend), but not in 2.0.0, and not in 2.1.0 when using a static sqlalchemy conn string.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] potiuk closed issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #16079:
URL: https://github.com/apache/airflow/issues/16079


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] potiuk edited a comment on issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

Posted by GitBox <gi...@apache.org>.
potiuk edited a comment on issue #16079:
URL: https://github.com/apache/airflow/issues/16079#issuecomment-849315935


   Ah. I see you updated the description @doowhtron and you'v come to the same fix I proposed :). Good!. Great minds think alike!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] potiuk commented on issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #16079:
URL: https://github.com/apache/airflow/issues/16079#issuecomment-849315381


   > I noticed this issue when using both a secret for sqlalchemy conn, and a custom secrets backend. It existed in Airflow 2.1.0 when using these two (sqlalchemy conn secret, and a custom secrets backend), but not in 2.0.0, and not in 2.1.0 when using a static sqlalchemy conn string.
   
   @theis @doowhtron -> would it be possible that you double-check the fix I proposed in: https://github.com/potiuk/airflow/commit/19742c1ffe78b6547b5a3f373be82e7c788f18c0 - it's a simple change in "airflow/configuration.py"  - just moving the validation a little later in the config. 
   
   Would be great to verify that the fix works :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] potiuk commented on issue #16079: NameError: name `conf` is not defined in configuration.py after upgraded to 2.1.0

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #16079:
URL: https://github.com/apache/airflow/issues/16079#issuecomment-849315935


   Ah. I see you updated the description @doowhtron and you'v come to the same fix I proposed :). Good


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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