Airflow:ValueError:无法配置处理程序“处理器” - wasb 记录器

Gag*_*gan 12 airflow airflow-scheduler

我正在尝试使用 Azure blob 配置远程日志记录。

Airflow version: 1.10.2
Python: 3.6.5
Ubuntu: 18.04
Run Code Online (Sandbox Code Playgroud)

以下是我所做的步骤:

  1. 在 $AIRFLOW_HOME/config/log_config.py 中,我放置了 REMOTE_BASE_LOG_FOLDER = 'wasb-airflow-logs' (这是容器内的一个文件夹(容器名称:airflow-logs))
  2. 空的init .py 位于 $AIRFLOW_HOME/config/ 中
  3. $AIRFLOW_HOME/config/ 添加到 $PYTHONPATH 中
  4. 将 $AIRFLOW_HOME/config/log_config.py 中的 DEFAULT_LOGGING_CONFIG 重命名为 LOGGING CONFIG
  5. Airflow blob 连接中定义的用户具有对 REMOTE_BASE_LOG_FOLDER 的读/写访问权限
  6. $AIRFLOW_HOME/airflow.cfg 它有remote_logging = Truelogging_config_class = log_config.LOGGING_CONFIG remote_log_conn_id =

以下是错误:

Unable to load the config, contains a configuration error.
Traceback (most recent call last):
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 382, in resolve
    found = getattr(found, frag)
AttributeError: module 'airflow.utils.log' has no attribute 'wasb_task_handler'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 384, in resolve
    self.importer(used)
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/utils/log/wasb_task_handler.py", line 23, in <module>
    from airflow.contrib.hooks.wasb_hook import WasbHook
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/contrib/hooks/wasb_hook.py", line 22, in <module>
    from airflow.hooks.base_hook import BaseHook
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/hooks/base_hook.py", line 28, in <module>
    from airflow.models import Connection
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/models.py", line 86, in <module>
    from airflow.utils.dag_processing import list_py_file_paths
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/utils/dag_processing.py", line 49, in <module>
    from airflow.settings import logging_class_path
ImportError: cannot import name 'logging_class_path'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 558, in configure
    handler = self.configure_handler(handlers[name])
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 708, in configure_handler
    klass = self.resolve(cname)
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 391, in resolve
    raise v
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 384, in resolve
    self.importer(used)
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/utils/log/wasb_task_handler.py", line 23, in <module>
    from airflow.contrib.hooks.wasb_hook import WasbHook
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/contrib/hooks/wasb_hook.py", line 22, in <module>
    from airflow.hooks.base_hook import BaseHook
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/hooks/base_hook.py", line 28, in <module>
    from airflow.models import Connection
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/models.py", line 86, in <module>
    from airflow.utils.dag_processing import list_py_file_paths
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/utils/dag_processing.py", line 49, in <module>
    from airflow.settings import logging_class_path
ValueError: Cannot resolve 'airflow.utils.log.wasb_task_handler.WasbTaskHandler': cannot import name 'logging_class_path'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gsingh/venv/bin/airflow", line 21, in <module>
    from airflow import configuration
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/__init__.py", line 36, in <module>
    from airflow import settings, configuration as conf
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/settings.py", line 262, in <module>
    logging_class_path = configure_logging()
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/logging_config.py", line 73, in configure_logging
    raise e
  File "/home/gsingh/venv/lib/python3.6/site-packages/airflow/logging_config.py", line 68, in configure_logging
    dictConfig(logging_config)
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 795, in dictConfig
    dictConfigClass(config).configure()
  File "/home/gsingh/anaconda3/lib/python3.6/logging/config.py", line 566, in configure
    '%r: %s' % (name, e))
ValueError: Unable to configure handler 'processor': Cannot resolve 'airflow.utils.log.wasb_task_handler.WasbTaskHandler': cannot import name 'logging_class_path'
Run Code Online (Sandbox Code Playgroud)

我不确定我缺少哪个配置。有人遇到过同样的问题吗?

Dom*_*vic 8

我遇到了同样的错误,但是如果我向上滚动,我可以看到在 ValueError 之前抛出了另一个异常。这是一个 PermissionError。

PermissionError: [Errno 13] Permission denied: '/usr/local/airflow/logs/scheduler'
Run Code Online (Sandbox Code Playgroud)

我收到该错误的原因是因为我在运行 Airflow docker 容器之前没有创建最初的 3 个文件夹(dags、logs、plugins)。所以docker似乎已经自动创建了,但是权限是错误的。

修复步骤:

  1. 停止当前容器
docker-compose down --volumes --remove-orphans
Run Code Online (Sandbox Code Playgroud)
  1. 删除文件夹 dags、日志、插件
  2. 以防万一 销毁已经创建的镜像和卷(在 Docker Desktop 中)
  3. 从命令行再次创建文件夹
mkdir logs dags plugins
Run Code Online (Sandbox Code Playgroud)
  1. 再次运行气流泊坞窗
docker-compose up airflow-init
docker-compose up
Run Code Online (Sandbox Code Playgroud)


Dan*_*Lee 3

您需要安装 azure 软件包。

pip install 'apache-airflow[azure_blob_storage,azure_data_lake,azure_cosmos,azure_container_instances]
Run Code Online (Sandbox Code Playgroud)

根据update.md

现在应该安装

pip install apache-airflow[azure]
Run Code Online (Sandbox Code Playgroud)

但这对我不起作用。