houqp commented on issue #14422:
URL: https://github.com/apache/airflow/issues/14422#issuecomment-821296305


   Interesting, I was expecting the second SIGTERM would have resulted in the 
task subprocess to set its own state in through `handle_failure` because 
`self.on_kill` calls `self.task_runner.terminate()`, which is supposed to wait 
for the subprocess to exit:
   
   
https://github.com/apache/airflow/blob/e7c642ba2a79ea13d6ef84b78242f6c313cd3457/airflow/task/task_runner/standard_task_runner.py#L108-L117
   
   >  We should probably add self.task_instance.state=State.FAILED in 
handle_task_exit if exit_code != 1. WDYT @houqp @ephraimbuddy ?
   
   I think we should do this as an extra safe guard because in rare cases, the 
task sub process could crash any time before it updates its own task state. 
However, I think the state update logic should be set with an extra condition:
   
   ```python
   if self.task_instance.state not in State.finished():
       self.task_instance.state = State.FAILED
   ```
   
   Because the task could have exited successfully right after the pod is 
getting killed but before local task job executes `handle_task_exit`.


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

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


Reply via email to