Fix KubernetesPodOperator succeeding after SIGTERM/on_kill interrupt - #71533
Open
sankalpsthakur wants to merge 2 commits into
Open
Fix KubernetesPodOperator succeeding after SIGTERM/on_kill interrupt#71533sankalpsthakur wants to merge 2 commits into
sankalpsthakur wants to merge 2 commits into
Conversation
sankalpsthakur
requested review from
hussein-awala,
jedcunningham and
jscheffl
as code owners
August 13, 2026 07:38
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
cleanup() returned early after on_kill(), so execute() looked like a clean success when SIGTERM hit the task process (spot drain / dual interrupt) even though the child pod never finished. Fixes apache#71202 Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
check-no-new-airflow-exceptions rejects a fourth raise AirflowException in pod.py. ruff-format also wants the raise on a single line. Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
sankalpsthakur
force-pushed
the
fix/71202-kpo-sigterm-success
branch
from
August 17, 2026 08:03
ad89bdc to
4f8b7a5
Compare
Author
|
Rebased onto main and used |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stripped False
len 4046
fier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
When KubernetesExecutor task pods and KubernetesPodOperator child pods are interrupted together (spot drain / dual SIGTERM), the task instance was finalized as SUCCESS even though the child never finished.
Root cause:
task_runnerSIGTERM handling callson_kill(), which sets_killedand deletes the child.cleanup()then returned immediately soexecute()completed normally. The supervisor records SUCCESS for a 0-exit with no terminal-state message. Interrupting only the child still failed (404 / PodFailed) becauseon_kill()never ran.This does not revert #69034 (warm-shutdown supervisor). SIGTERM on the supervisor is still not treated as task failure. The change is KPO-only: after
on_kill(), cleanup still skips a second delete (avoids 404 retries) but raisesAirflowExceptionso the TI is failed / up_for_retry.Summary
KubernetesPodOperator.cleanup()raises ifon_kill()already ran, instead of returning as success._killedcleanup path and the execute_sync race (SIGTERM/on_kill during wait, then execute continues).Validation
apache-airflow-providers-cncf-kubernetes==10.21.0:cleanup()after_killed=TruereturnedNone(the SUCCESS bug).AirflowException: Pod sleep-worker was interrupted before it completed.test_cleanup_raises_when_on_kill_already_rantest_execute_sync_on_kill_during_wait_is_not_successtest_pod.pyfile isdb_test(breeze). Local proof used Airflow 3.1.3 + overlaid operator module, no live cluster.Fixes #71202
AI/LLM disclosure
Was generative AI tooling used to co-author this PR?
Generated-by: Grok (Cursor agent) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.