RNHTTR commented on code in PR #42005:
URL: https://github.com/apache/airflow/pull/42005#discussion_r1813233019


##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1684,7 +1684,19 @@ def _schedule_dag_run(
                     .where(TI.state.in_(State.unfinished))
                 )
                 for task_instance in unfinished_task_instances:
+                    # If the DAG is set to kill the task instances on timeout, 
we call on_kill
+                    # otherwise we just skip the task instance
                     task_instance.state = TaskInstanceState.SKIPPED
+                    if dag.call_on_kill_on_dagrun_timeout:
+                        task = dag.get_task(task_instance.task_id)
+                        if hasattr(task, "on_kill"):
+                            try:
+                                task.on_kill()
+                                task_instance.state = TaskInstanceState.FAILED
+                            except Exception as e:
+                                self.log.error("Error when calling on_kill for 
task %s: %s", task_instance, e)
+                        else:
+                            self.log.warning("Task %s does not have on_kill 
method, skipping", task_instance)

Review Comment:
   ```suggestion
                               self.log.info("Task %s does not have on_kill 
method, skipping", task_instance)
   ```



-- 
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