gpt4 book ai didi

docker - 再次启动现有但已退出的 Airflow 容器时,Fernet key 无效

转载 作者:行者123 更新时间:2023-12-02 18:18:59 26 4
gpt4 key购买 nike

我使用 FERNET_KEY 进行了 dockerized Airflow 服务作为使用 .env 导出的环境变量文件(其中还包括除 FERNET_KEY 之外的其他环境变量)。

当我构建并运行 docker 容器时, Airflow 服务按预期运行,然后我转到连接并在 Airflow UI 中设置我的 AWS 连接,如此处所述 https://airflow.apache.org/howto/connection/aws.html .到现在为止还挺好。现在,我故意停止 docker 容器,然后再次启动容器并转到 Airflow UI--> Connections 以查看我的 AWS 连接设置是否仍然存在(我在停止容器之前配置)。

但是,这就是发生的事情。当我去看aws_default在 Airflow UI 中设置,我看到如下错误

Ooops.

____/ ( ( ) ) \___
/( ( ( ) _ )) ) )\
(( ( )( ) ) ( ) )
((/ ( _( ) ( _) ) ( () ) )
( ( ( (_) (( ( ) .((_ ) . )_
( ( ) ( ( ) ) ) . ) ( )
( ( ( ( ) ( _ ( _) ). ) . ) ) ( )
( ( ( ) ( ) ( )) ) _)( ) ) )
( ( ( \ ) ( (_ ( ) ( ) ) ) ) )) ( )
( ( ( ( (_ ( ) ( _ ) ) ( ) ) )
( ( ( ( ( ) (_ ) ) ) _) ) _( ( )
(( ( )( ( _ ) _) _(_ ( (_ )
(_((__(_(__(( ( ( | ) ) ) )_))__))_)___)
((__) \\||lll|l||/// \_))
( /(/ ( ) ) )\ )
( ( ( ( | | ) ) )\ )
( /(| / ( )) ) ) )) )
( ( ((((_(|)_))))) )
( ||\(|(|)|/|| )
( |(||(||)|||| )
( //|/l|||)|\\ \ )
(/ / // /|//||||\\ \ \ \ _)
-------------------------------------------------------------------------------
Node: 64e7a509837f
-------------------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.7/site-packages/flask_admin/base.py", line 69, in inner
return self._run_view(f, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_admin/base.py", line 368, in _run_view
return fn(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_admin/model/base.py", line 2125, in edit_view
form = self.edit_form(obj=model)
File "/usr/local/lib/python3.7/site-packages/flask_admin/model/base.py", line 1340, in edit_form
return self._edit_form_class(get_form_data(), obj=obj)
File "/usr/local/lib/python3.7/site-packages/wtforms/form.py", line 212, in __call__
return type.__call__(cls, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_admin/form/__init__.py", line 16, in __init__
super(BaseForm, self).__init__(formdata=formdata, obj=obj, prefix=prefix, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wtforms/form.py", line 278, in __init__
self.process(formdata, obj, data=data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/wtforms/form.py", line 127, in process
if obj is not None and hasattr(obj, name):
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 353, in __get__
retval = self.descriptor.__get__(instance, owner)
File "/usr/local/lib/python3.7/site-packages/airflow/models/connection.py", line 155, in get_password
return fernet.decrypt(bytes(self._password, 'utf-8')).decode()
File "/usr/local/lib/python3.7/site-packages/cryptography/fernet.py", line 171, in decrypt
raise InvalidToken
cryptography.fernet.InvalidToken

我可能会遗漏一些关于 Fernet key 的概念。每次我的 docker 容器启动时,我是否必须生成新的 fernet key ?如果是这样,当 docker 正在构建时,我应该如何即时生成? FERNET_KEY我注入(inject)到 .env文件实际上是在我的本地计算机中生成并复制到 .env docker 正在使用的文件(FERNET_KEY=4EPOSLXXXXXXXXXXXIERu=)

最佳答案

您不需要即时生成新 key 。您可能遗漏了一些东西,您是否尝试连接到您的 docker 机器并从终端打印 FERNET_KEY 以检查它是否真的被加载?

$ docker exec -it <CONTAINER ID> bash
(now, inside the container) # echo ${FERNET_KEY}

如果它与您的 env 文件不同,则说明有问题。您使用的是 docker-compose 环境吗?如果是这样,您还需要对 docker-compose.yml 进行以下操作:
environment:
- FERNET_KEY=${FERNET_KEY}

关于docker - 再次启动现有但已退出的 Airflow 容器时,Fernet key 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58644928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com