Consider XCOM sidecar container during pod cleanup#64962
Merged
jscheffl merged 7 commits intoApr 15, 2026
Merged
Conversation
wolfdn
requested review from
hussein-awala,
jedcunningham and
jscheffl
as code owners
April 9, 2026 12:56
jscheffl
reviewed
Apr 9, 2026
jscheffl
left a comment
Contributor
There was a problem hiding this comment.
Implementation looks good but some tests are failing.
Contributor
Author
Just fixed the failing unit tests. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates KubernetesPodOperator pod monitoring/cleanup to better handle the XCom sidecar case where the base container completes but the pod remains in Running, preventing indefinite waits and avoiding incorrect task failure decisions.
Changes:
- Extend
PodManager.await_pod_completionto optionally stop waiting once the base container completes when an XCom sidecar is expected. - Update deferrable operator cleanup to pass
do_xcom_pushinto pod completion waiting and to use base container status for success/failure when sidecars are involved. - Add unit tests covering the new XCom-sidecar behavior for both
await_pod_completionandcleanup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py | Adds do_xcom_push flag to allow early exit when base container completes but pod phase stays non-terminal due to a sidecar. |
| providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py | Threads do_xcom_push into the deferrable cleanup wait path and refactors failure detection for sidecar scenarios. |
| providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_pod_manager.py | Adds tests validating early-exit behavior for XCom sidecar vs. no-sidecar behavior. |
| providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_pod.py | Adds a cleanup test asserting task outcome is based on base container exit code when an XCom sidecar keeps the pod running. |
Contributor
|
No luck with CI - can you apply some more fixes to tests? |
…-sidecar-container-during-cleanup
wolfdn
requested review from
ashb,
gopidesupavan,
jason810496 and
potiuk
as code owners
April 15, 2026 07:29
potiuk
approved these changes
Apr 15, 2026
eladkal
approved these changes
Apr 15, 2026
karenbraganz
pushed a commit
to karenbraganz/airflow
that referenced
this pull request
Apr 16, 2026
* Consider XCOM sidecar container during pod cleanup * Fix failing unit tests * Apply Copilot review findings * Implement Copilot review finding regarding failed status * Fix some more unit tests * More fixes for unit tests
60 tasks
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
do_xcom_push=Truewith theKubernetesPodOperator, an xcom sidecar container is injected into the pod to facilitate XCom value transfer. If communication with the Kubernetes API fails during cleanup (e.g. the kill command for the sidecar cannot be sent), the xcom sidecar container may remain running even after the base container has completed.In this scenario,
await_pod_completionwaits indefinitely for the pod to reach a terminal phase — which never happens because the still-running xcom sidecar keeps the pod in theRunningphase.Additionally, the
cleanupmethod determines task success/failure based on the overall pod phase rather than the base container's status. When the xcom sidecar prevents the pod from reachingSucceeded, a task whose base container completed successfully is incorrectly marked as failed.Solution
This change extends the existing istio sidecar handling to also cover the xcom sidecar container:
await_pod_completion(pod_manager.py): Whendo_xcom_push=True, break out of the pod-completion wait loop as soon as the base container has completed — just like the existing behavior for istio sidecars. A log message is emitted to make this early exit visible.cleanup(pod.py): Whendo_xcom_push=True, determine task success/failure based on the base container's exit status rather than the overall pod phase. This prevents a lingering xcom sidecar from causing a false failure.Changes
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.pydo_xcom_pushparameter toawait_pod_completionistio_enabledtoistio_enabled or do_xcom_pushproviders/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.pyself.do_xcom_pushtoawait_pod_completionin_cleanfaileddetermination incleanupto check base container status whendo_xcom_pushis enabledWas generative AI tooling used to co-author this PR?
GitHub Copilot - Claude Opus 4.6
{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.