cncf-kubernetes: fix potential race condition in trigger_reentry flow caused by is_istio_enabled#69269
Open
noah-gil wants to merge 3 commits into
Open
cncf-kubernetes: fix potential race condition in trigger_reentry flow caused by is_istio_enabled#69269noah-gil wants to merge 3 commits into
is_istio_enabled#69269noah-gil wants to merge 3 commits into
Conversation
is_istio_enabledis_istio_enabled
|
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
|
noah-gil
force-pushed
the
fix/trigger-resume-pod-removed-race
branch
from
July 9, 2026 20:39
5696cd4 to
a128eba
Compare
noah-gil
marked this pull request as ready for review
July 9, 2026 20:40
noah-gil
requested review from
hussein-awala,
jedcunningham and
jscheffl
as code owners
July 9, 2026 20:40
noah-gil
force-pushed
the
fix/trigger-resume-pod-removed-race
branch
from
July 14, 2026 17:27
a128eba to
6f652ed
Compare
This is meant to catch a potential race condition in the `trigger_reentry` flow. There is already a check that the pod still exists in the event of a success, but it is still possible for the pod to be removed during the first and second API read. Should this happen, we should return the same way as if no pod was provided to the function.
noah-gil
force-pushed
the
fix/trigger-resume-pod-removed-race
branch
from
July 15, 2026 14:50
6f652ed to
31f04ec
Compare
Miretpl
requested changes
Jul 15, 2026
Contributor
Not only here, as far as I checked, but in general yes, that is a really nice catch |
Miretpl
approved these changes
Jul 17, 2026
Contributor
|
I will wait a day or two to merge if anyone also wants to provide feedback on it. |
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.
Problem
When using the deferred
KubernetesPodOperator, there is a potential race condition in thetrigger_reentrysuccess flow. After a pod has completed and the worker resumes the workload from the triggerer, it reads the pod from the Kubernetes API, checking that it still exists:It then continues down the happy path until it reaches this part in
_clean:Then it
is_istio_enabled, it attempts a second pod read from the Kubernetes API:At this point, it is possible that the pod has now been deleted by some external factor during the time between the first and second pod read. Should this occur, the task fails due to a raised
ApiExceptionerror. Even though the pod succeeded, it is marked as error due to this failed API read, exactly what the first read tried to check for.Solution
I chose to mimic the existing case of returning
Falsewhen there is no pod provided in the function's argument. It narrowly catches the 404 and returns false, while still re-raising an exception for any other API error. I am open for discussion on other approaches for this fix. As this is quite a small patch, do let me know if I should create any tests to test for this exact scenario.Thank you for your time!
Was generative AI tooling used to co-author this PR?