[ 
https://issues.apache.org/jira/browse/AIRFLOW-6250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16997123#comment-16997123
 ] 

ASF subversion and git services commented on AIRFLOW-6250:
----------------------------------------------------------

Commit 1006740aa92d584cfb0317c922184ef758bf108a in airflow's branch 
refs/heads/master from yuqian90
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=1006740 ]

[AIRFLOW-6250] Ensure on_failure_callback always has a populate context (#6812)

on_failure_callback almost always want to know the dag_id and taskinstance that 
failed. These info are in the context passed to on_failure_callback, which is 
passed in from handle_failure(). However, in some rare scenarios, if 
handle_failure is called in scheduler_job.py and backfill_job.py, the only 
argument passed is the error message. context is left as None.

So in these cases, on_failure_callback will not even know what's the dag_id of 
the dag that just failed.

This PR fixes this by setting context to get_template_context() if it's not 
given.

> on_failure_callback does not know the task_id when handle_failure() is called 
> without passing context
> -----------------------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-6250
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6250
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: scheduler
>    Affects Versions: 1.10.6
>            Reporter: Qian Yu
>            Assignee: Qian Yu
>            Priority: Major
>             Fix For: 1.10.7
>
>
> The following code in scheduler_job.py can be hit e.g when 
> {{send_task_to_executor()}} in celery_executor.py is too slow and times out 
> after 2 seconds. But this call to {{handle_failure}}() is not passing a 
> {{context}} object.
> So the {{on_failure_callback}} and on_retry_callback of tasks don't have an 
> idea about what task failed.
>   
>  This can be fixed by making handle_failure() derive some reasonable default 
> value for the context argument.
>   
> {code:python}
>     simple_dag = simple_dag_bag.get_dag(dag_id)
>     dagbag = models.DagBag(simple_dag.full_filepath)
>     dag = dagbag.get_dag(dag_id)
>     ti.task = dag.get_task(task_id)
>     ti.handle_failure(msg)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to