【发布时间】:2019-11-13 23:23:41
【问题描述】:
我在 Centos 7 中使用 Airflow,使用 Python 3.7。
当我通过 BashOperator 运行 Bash 命令时,我遇到了以下问题:
[2019-11-13 23:20:08,238] {taskinstance.py:1058} ERROR - [Errno 2] No such file or directory: 'bash': 'bash'
Traceback (most recent call last):
File "/home/airflow/virtualenvs/airflow_env/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 930, in _run_raw_task
result = task_copy.execute(context=context)
File "/home/airflow/virtualenvs/airflow_env/lib/python3.7/site-packages/airflow/operators/bash_operator.py", line 120, in execute
preexec_fn=pre_exec)
File "/home/airflow/python/Python-3.7.5/Lib/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "/home/airflow/python/Python-3.7.5/Lib/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'bash': 'bash'
我需要将一个变量传递给 BashOperator 以便它知道查找 /bin/bash 吗?在源代码中,BashOperator 似乎使用bash 打开了一个子进程;我需要修改它以使用/bin/bash吗?
【问题讨论】:
-
您是在容器中还是在本地运行 Airflow?无论哪种方式,请尝试运行
bash以检查是否可以找到该命令。另外,也许你也应该发布你正在运行的 bash 命令。 -
能否将任务定义代码包含在 dag 中?
-
它是计划的 DAG 运行,还是您在命令行中使用
airflow test ...?奇怪的是/bin/不在该进程的$PATH上。