我正在使用Airflow 1.9,并使用“ pip install apache-airflow [all]”进行了安装。尝试使用LDAP身份验证时,出现以下错误。
Aug 6 10:26:07 test-airflow airflow: [2018-08-06 10:26:07,364] {__init__.py:64} CRITICAL - Cannot import authentication module airflow.contrib.auth.backends.ldap_auth. Please correct your authentication backend or disable authentication: cannot import name NoValue
Aug 6 10:26:07 test-airflow airflow: Traceback (most recent call last):
Aug 6 10:26:07 test-airflow airflow: File "/bin/airflow", line 27, in <module>
Aug 6 10:26:07 test-airflow airflow: args.func(args)
Aug 6 10:26:07 test-airflow airflow: File "/usr/lib/python2.7/site-packages/airflow/bin/cli.py", line 678, in webserver
Aug 6 10:26:07 test-airflow airflow: app = cached_app(conf)
Aug 6 10:26:07 test-airflow airflow: File "/usr/lib/python2.7/site-packages/airflow/www/app.py", line 161, in cached_app
Aug 6 10:26:07 test-airflow airflow: app = create_app(config)
Aug 6 10:26:07 test-airflow airflow: File "/usr/lib/python2.7/site-packages/airflow/www/app.py", line 44, in create_app
Aug 6 10:26:07 test-airflow airflow: airflow.load_login()
Aug 6 10:26:07 test-airflow airflow: File "/usr/lib/python2.7/site-packages/airflow/__init__.py", line 67, in load_login
Aug 6 10:26:07 test-airflow airflow: raise AirflowException("Failed to import authentication backend")
Aug 6 10:26:07 test-airflow airflow: airflow.exceptions.AirflowException: Failed to import authentication backend
Aug 6 10:26:07 test-airflow systemd: airflow-webserver.service: main process exited, code=exited, status=1/FAILURE
Aug 6 10:26:07 test-airflow systemd: Unit airflow-webserver.service entered failed state.
Aug 6 10:26:07 test-airflow systemd: airflow-webserver.service failed.
这是我的airflow.cfg:
[webserver]
authenticate = True
auth_backend = airflow.contrib.auth.backends.ldap_auth
base_url = http://test-airflow.example.com
答案 0 :(得分:0)
由于日志条目的限制,您的问题可能会有所不同,但这是我在遇到此问题时发现的:
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: [2018-08-21 04:56:45,150] {__init__.py:64} CRITICAL - Cannot import authentication module airflow.contrib.auth.backends.ldap_auth. Please correct your authentication backend or disable au
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: Traceback (most recent call last):
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/__init__.py", line 59, in load_login
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: login = import_module(auth_backend)
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: return _bootstrap._gcd_import(name[level:], package, level)
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap>", line 986, in _gcd_import
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap>", line 969, in _find_and_load
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap_external>", line 665, in exec_module
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/contrib/auth/backends/ldap_auth.py", line 23, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from ldap3 import Server, Connection, Tls, LEVEL, SUBTREE, BASE
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/ldap3/__init__.py", line 138, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from .core.connection import Connection
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/ldap3/core/connection.py", line 37, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from ..extend import ExtendedOperationsRoot
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/ldap3/extend/__init__.py", line 45, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from .standard.whoAmI import WhoAmI
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/ldap3/extend/standard/whoAmI.py", line 27, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from pyasn1.type.univ import NoValue
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: ImportError: cannot import name 'NoValue'
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: During handling of the above exception, another exception occurred:
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: Traceback (most recent call last):
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/bin/airflow", line 27, in <module>
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: args.func(args)
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/bin/cli.py", line 678, in webserver
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: app = cached_app(conf)
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/www/app.py", line 161, in cached_app
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: app = create_app(config)
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/www/app.py", line 44, in create_app
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: airflow.load_login()
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: File "/usr/local/lib/python3.5/dist-packages/airflow/__init__.py", line 67, in load_login
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: raise AirflowException("Failed to import authentication backend")
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: airflow.exceptions.AirflowException: Failed to import authentication backend
Aug 21 04:56:45 ip-10-202-21-240 systemd[1]: airflow-webserver.service: Main process exited, code=exited, status=1/FAILURE
Aug 21 04:56:45 ip-10-202-21-240 systemd[1]: airflow-webserver.service: Unit entered failed state.
Aug 21 04:56:45 ip-10-202-21-240 systemd[1]: airflow-webserver.service: Failed with result 'exit-code'.
请注意以下部分:
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: from pyasn1.type.univ import NoValue
Aug 21 04:56:45 ip-10-202-21-240 airflow[10065]: ImportError: cannot import name 'NoValue'
我拥有的pyasn1的版本似乎旧了。一旦我强迫pip下载最新版本
sudo pip install pyasn1==0.4.4
成功了
答案 1 :(得分:0)
我安装了ldap3来解决它。
pip install ldap3