eladkal commented on issue #56196:
URL: https://github.com/apache/airflow/issues/56196#issuecomment-3355796770

   I was pretty sure I already commented on this issue (?) maybe I just 
prepared a comment and didn't hit submit :bowtie: 
   
   > When a task with remaining retries fails, the on_retry_callback should be 
executed and NOT on_failure_callback.
   
   Yes but this is not the case you are describing.
   You describe a case where the task is killed. Killed = task goes to failure 
state which means that `on_failure_callback` must be executed so the issue here 
is not if `on_failure_callback` should be executed - the answer to that is 
always yes. The issue here is if  `on_retry_callback` should be called as well.
   
   Let me demonstrate an example:
   
   ```
   from airflow import DAG
   from airflow.decorators import task
   from airflow.exceptions import AirflowFailException
   from datetime import datetime
   
   def on_failure_callback(context):
       print("Task failed")
   
   def on_retry_callback(context):
       print("Task retrying")
   
   @task(retries=3, on_failure_callback=on_failure_callback, 
on_retry_callback=on_retry_callback)
   def failing_task():
       raise AirflowFailException("Task failed")
   
   dag = DAG(
       "test_dag",
       start_date=datetime(2024, 1, 1),
       schedule=None,
   )
   
   failing_task()
   ```
   
   What would you expect to happen in this case?
   there are 3 retries but no retries will ever be invoked. Do you expect 
`on_retry_callback` to be called? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to