我正在尝试为运行气流服务器的 gcp vm 启用 Web 身份验证。我使用官方文档来更新配置文件:
[webserver]
authenticate = True
auth_backend = airflow.contrib.auth.backends.password_auth
以及在元数据库中创建一个用户。
$ cd ~/airflow
$ python
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
Type "help", "copyright", "credits" or "license" for more information.
>>> import airflow
>>> from airflow import models, settings
>>> from airflow.contrib.auth.backends.password_auth import PasswordUser
>>> user = PasswordUser(models.User())
>>> user.username = 'new_user_name'
>>> user.email = 'new_user_email@example.com'
>>> user.password = 'set_the_password'
>>> session = settings.Session()
>>> session.add(user)
>>> session.commit()
>>> session.close()
>>> exit()
上面的密码部分出错了,所以我按照这里的建议运行了以下命令:
user._set_password = ‘………….’.encode('utf8')
此后python终端没有错误,我假设用户已在元数据库中成功创建。此后我初始化了 db ,这导致了一个错误:
$ airflow initdb
....
....
File "/usr/lib/python2.7/base64.py", line 119, in urlsafe_b64decode
return b64decode(s.translate(_urlsafe_decode_translation))
File "/usr/lib/python2.7/base64.py", line 78, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding
我不知道为什么,但是设置Fernet 密钥很有帮助,我可以运行 initdb 而不会出现任何错误:
~$ airflow initdb
[2018-06-07 20:58:58,301] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-06-07 20:58:58,322] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[2018-06-07 20:58:58,447] {__init__.py:45} INFO - Using executor LocalExecutor
[2018-06-07 20:58:58,546] {db.py:312} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
[2018-06-07 20:58:59,982] {models.py:189} INFO - Filling up the DagBag from /home/username/airflow/dags
Done.
但是......当我想运行网络服务器时,它不起作用:
$ airflow webserver -p 8080
....
....
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 27, in <module>
args.func(args)
File "/usr/local/lib/python2.7/dist-packages/airflow/bin/cli.py", line 678, in webserver
app = cached_app(conf)
File "/usr/local/lib/python2.7/dist-packages/airflow/www/app.py", line 161, in cached_app
app = create_app(config)
File "/usr/local/lib/python2.7/dist-packages/airflow/www/app.py", line 52, in create_app
app=app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp'})
File "/usr/local/lib/python2.7/dist-packages/flask_cache/__init__.py", line 121, in __init__
self.init_app(app, config)
File "/usr/local/lib/python2.7/dist-packages/flask_cache/__init__.py", line 156, in init_app
from .jinja2ext import CacheExtension, JINJA_CACHE_ATTR_NAME
File "/usr/local/lib/python2.7/dist-packages/flask_cache/jinja2ext.py", line 33, in <module>
from flask.ext.cache import make_template_fragment_key
ImportError: No module named ext.cache
有人指出我这个问题:
我安装了这两个软件包,但问题仍然存在:
有没有人有进一步解决这个问题的建议?