Retry KubernetesPodOperator pod launch when preempted before it starts - #70274
Open
imrichardwu wants to merge 2 commits into
Open
Retry KubernetesPodOperator pod launch when preempted before it starts#70274imrichardwu wants to merge 2 commits into
imrichardwu wants to merge 2 commits into
Conversation
imrichardwu
requested review from
hussein-awala,
jedcunningham and
jscheffl
as code owners
July 23, 2026 05:56
imrichardwu
force-pushed
the
fix/k8s-pod-operator-404
branch
from
July 23, 2026 16:02
090255f to
8c91190
Compare
Contributor
|
Quickest fix: git fetch upstream main && git rebase upstream/main
rm uv.lock && uv lock
git add uv.lock && git rebase --continue
git push --force-with-leaseAutomated nudge — ignore if you're not ready to rebase. This comment is updated in place on future |
- Added `retry_on_pod_not_found` parameter to `KubernetesPodOperator` to allow automatic relaunching of pods that disappear before their base container starts, addressing issues with pod preemption or eviction. - Introduced `pod_not_found_max_retries` parameter to control the maximum number of relaunch attempts. - Updated `AsyncKubernetesHook` to raise `PodNotFoundException` for 404 errors, enabling better error handling. - Enhanced unit tests to cover new retry behavior and validate correct exception handling for pod not found scenarios.
- Introduced optional dependency group "standard" in both `uv.lock` and `pyproject.toml` to include `apache-airflow-providers-standard`. - Updated documentation to reflect the new optional dependencies and installation instructions for users. - Modified unit tests to ensure compatibility with the new dependency structure.
imrichardwu
force-pushed
the
fix/k8s-pod-operator-404
branch
from
July 29, 2026 05:48
88ebd0c to
b793741
Compare
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.
On autoscaling Kubernetes clusters (for example, Karpenter), a
KubernetesPodOperatortask pod can be preempted by a higher-priority DaemonSet before it ever starts running. Today, that surfaces as a rawApiException(404)and fails the task immediately.This PR adds an opt-in
retry_on_pod_not_foundflag (withpod_not_found_max_retries) to relaunch the pod only if it disappeared before the base container could have started, making retries safe because no user workload has executed. If the base container may have started, the task behaves exactly as it does today and the pod is never recreated.The retry logic works in both synchronous and deferrable (
deferrable=True) execution modes with exponential backoff between attempts.This PR also fixes
AsyncKubernetesHook.get_pod()to raisePodNotFoundExceptionon HTTP 404, matching the synchronous implementation.related: #59626
Was generative AI tooling used to co-author this PR?
{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.