我正在通过下面的API触发DAG来执行python脚本来运行命令。
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: application/json" http://localhost:8080/api/experimental/dags/DAG-3/dag_runs -d '{"conf":"{\"hostname\":\"<servername>\",\"username\":\"test\", \"password\":\"<password>\", \"command1\":\"uname -a\" }"}'当执行curl时,我得到如下响应
{"execution_date":"2020-07-17T18:26:58+00:00","message":"Created <DagRun DAG-3 @ 2020-07-17 18:26:58+00:00: manual__2020-07-17T18:26:58+00:00, externally triggered: True>"}我可以在DAG日志中看到脚本成功执行,
[2020-07-17 18:25:03,982] {bash_operator.py:122} INFO - Output:
[2020-07-17 18:25:04,303] {bash_operator.py:126} INFO - Linux servername 3.10.0-693.21.1.el7.x86_64 #1 SMP Fri Feb 23 18:54:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[2020-07-17 18:25:04,321] {bash_operator.py:130} INFO - Command exited with return code 0但我需要此输出必须作为JSON响应返回,我如何才能实现它。谢谢
发布于 2020-07-18 17:44:12
Airflow API是异步的,因为您的curl只是启动了一次DAG运行-它不会等到它完成(因为我们无法知道它需要多长时间才能完成,可能是几天,也可能是几周)。
Airflow API仍处于开发阶段,AFAIK无法从中检索DAG运行的日志
https://stackoverflow.com/questions/62966992
复制相似问题