You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/05/25 06:28:22 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.

uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1205050272


##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,13 @@ def add_logger_if_needed(ti: TaskInstance):
         # than creating a BackfillJob and allows us to surface logs to the user
         while dr.state == State.RUNNING:
             schedulable_tis, _ = dr.update_state(session=session)
-            for ti in schedulable_tis:
-                add_logger_if_needed(ti)
-                ti.task = tasks[ti.task_id]
-                _run_task(ti, session=session)
+            try:
+                for ti in schedulable_tis:
+                    add_logger_if_needed(ti)
+                    ti.task = tasks[ti.task_id]
+                    _run_task(ti, session=session)
+            except Exception:
+                self.log.info("Task failed, continue looping. DAG will be marked as failed at the end of looping.")

Review Comment:
   ```suggestion
                   self.log.info(
                       "Task failed. DAG will continue to run until finished "
                       "and be marked as failed."
                   )
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org