任务失败时无法接收电子邮件,甚至使用 EmailOperator 时也无法接收电子邮件
嗨,大家好,
即使添加了发送电子邮件所需的参数后,我也无法从我的邮箱接收电子邮件。
下面是我的默认参数的样子——
default_args = {
'owner': 'phonrao',
'depends_on_past': False,
#'start_date': datetime(2019, 3, 28),
'start_date': airflow.utils.dates.days_ago(2),
'email': ['phonrao@gmail.com'],
'email_on_failure': True,
'email_on_retry': True,
'retries': 1,
'retry_delay': timedelta(minutes=5),
#'on_failure_callback': report_failure,
#'end_date': datetime(2020,4 ,1),
#'schedule_interval': '@hourly',
}
Run Code Online (Sandbox Code Playgroud)
我中间有几个 HttpsOperator 任务——这些任务运行良好并且成功,但它们不会在错误时发送电子邮件(我故意尝试引入一个错误来检查它们是否发送任何电子邮件)。下面是我的任务的一个例子。
t1 = SimpleHttpOperator(
task_id='t1',
http_conn_id='http_waterfall',
endpoint='/update_data',
method='POST',
headers={"Content-Type":"application/json"},
xcom_push=True,
log_response=True,
dag=dag,
)
Run Code Online (Sandbox Code Playgroud)
这是我的 EmailOperator 任务
t2 = EmailOperator(
dag=dag,
task_id="send_email",
to='phonrao@gmail.com',
subject='Success',
html_content="<h3>Success</h3>"
)
t2 >> t1
Run Code Online (Sandbox Code Playgroud)
以下是日志中的错误:
[2019-04-02 15:28:21,305] {{base_task_runner.py:101}} INFO - Job 845: Subtask send_email [2019-04-02 15:28:21,305] {{cli.py:520}} …Run Code Online (Sandbox Code Playgroud)