Python AirflowException:conn_id`http_default`isn';尝试在应用程序中运行HTTP运算符时出现t定义的错误
我有一个DAG,作为最后一个任务,它需要发送一个HTTP请求来触发Google云功能。我正在测试它,但是HTTP任务失败了 任务定义:Python AirflowException:conn_id`http_default`isn';尝试在应用程序中运行HTTP运算符时出现t定义的错误,python,http,airflow,Python,Http,Airflow,我有一个DAG,作为最后一个任务,它需要发送一个HTTP请求来触发Google云功能。我正在测试它,但是HTTP任务失败了 任务定义: send_standby_signal = ho.SimpleHttpOperator( task_id = 'send-k8s-cluster-standby-signal', endpoint = 'https://path-to-function-endpoint', method = 'POST',
send_standby_signal = ho.SimpleHttpOperator(
task_id = 'send-k8s-cluster-standby-signal',
endpoint = 'https://path-to-function-endpoint',
method = 'POST',
data = '',
trigger_rule = trigger_rule.TriggerRule.ALL_DONE
)
错误:
[2019-10-02 13:57:29,088] {http_operator.py:87} INFO - Calling HTTP method
[2019-10-02 13:57:29,122] {__init__.py:1580} ERROR - The conn_id `http_default` isn't defined
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 1441, in _run_raw_task
result = task_copy.execute(context=context)
File "/usr/local/lib/python3.7/site-packages/airflow/operators/http_operator.py", line 92, in execute
self.extra_options)
File "/usr/local/lib/python3.7/site-packages/airflow/hooks/http_hook.py", line 101, in run
session = self.get_conn(headers)
File "/usr/local/lib/python3.7/site-packages/airflow/hooks/http_hook.py", line 60, in get_conn
conn = self.get_connection(self.http_conn_id)
File "/usr/local/lib/python3.7/site-packages/airflow/hooks/base_hook.py", line 80, in get_connection
conn = random.choice(cls.get_connections(conn_id))
File "/usr/local/lib/python3.7/site-packages/airflow/hooks/base_hook.py", line 75, in get_connections
conns = cls._get_connections_from_db(conn_id)
File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 73, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/airflow/hooks/base_hook.py", line 58, in _get_connections_from_db
"The conn_id `{0}` isn't defined".format(conn_id))
airflow.exceptions.AirflowException: The conn_id `http_default` isn't defined
答案很简单,真的。我没有在Airflow Connections中定义
http\u default
。多么尴尬。我在airflow UI中定义了连接,但我仍然面临同样的问题。正在寻找解决方案。对我来说,同样的问题,连接是在Airflow UI上定义的,但DAG无法访问它。。。奇怪:(