【问题标题】:Airflow DeprecationWarning气流弃用警告
【发布时间】:2023-01-16 16:21:27
【问题描述】:

我正在使用官方 Docker 映像运行分布式 Airflow 2.4.0 安装程序。所有容器都使用相同的.env 文件和相同版本的 Airflow 图像。当我登录其中一个 Airflow 容器时,我收到此警告:

/home/airflow/.local/lib/python3.7/site-packages/airflow/configuration.py:545: DeprecationWarning: The sql_alchemy_conn option in [core] has been moved to the sql_alchemy_conn option in [database] - the old setting has been used, but please update your config.
  option = self._get_environment_variables(deprecated_key, deprecated_section, key, section)
/home/airflow/.local/lib/python3.7/site-packages/airflow/configuration.py:545: DeprecationWarning: The auth_backend option in [api] has been renamed to auth_backends - the old setting has been used, but please update your config.
  option = self._get_environment_variables(deprecated_key, deprecated_section, key, section)
/home/airflow/.local/lib/python3.7/site-packages/airflow/configuration.py:367: FutureWarning: The auth_backends setting in [api] has had airflow.api.auth.backend.session added in the running config, which is needed by the UI. Please update your config before Apache Airflow 3.0.
  FutureWarning,

我检查了容器内的airflow.cfg,它有最新的变量。为什么我仍然收到警告消息?

【问题讨论】:

    标签: airflow


    【解决方案1】:

    由于该部分,您会看到这些变量。 airflow.cfg 是带节的配置文件。设置应该在适当的部分。

    在您的情况下,您的 airflow.cfg 具有 sql_alchemy_conn,您可以在其中覆盖默认值。在 2.3.0 之前,此设置位于 core section 中,而在 2.3.0 中,它已移至 database section。 (见PR

    您需要做的只是打开airflow.cfg并将设置移动到适当的部分。例如:

    [core]
    
    sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/airflow.db
    

    到:

    [database]
    
    sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/airflow.db
    

    为什么会这样,在docs中也有解释。通过格式为 AIRFLOW__{SECTION}__{KEY} 的环境变量进行气流参考设置,因此在这种情况下它将是: AIRFLOW__DATABASE__SQL_ALCHEMY_CONN 因此该部分对于查找变量很重要。

    【讨论】:

    • 有效!我更改了 docker-compose .env 中的变量并重新启动了容器。起初让我失望的是,这些变量在容器内的 airflow.cfg 中正确设置。事实上,我认为 docker-compose 将使用这些值来呈现 airflow.cfg 文件,但显然发生了其他事情。
    • $docker exec -it docker_airflow-webserver_1 airflow config get-value api auth_backends airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session$docker exec -it docker_airflow-webserver_1 cat airflow.cfg | grep auth_backends auth_backends = airflow.api.auth.backend.session
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-11
    • 2021-07-12
    • 2017-08-22
    • 2011-09-29
    • 2018-09-08
    相关资源
    最近更新 更多