Skip to content

Fix KubernetesPodOperator XCom loss when container_logs is a string - #72502

Merged
potiuk merged 1 commit into
apache:mainfrom
henry3260:fix-kpo-container-logs-substring-match
Sep 8, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
henry3260:fix-kpo-container-logs-substring-match

Conversation

@henry3260

Copy link
Copy Markdown
Contributor

Why

KubernetesPodOperator.await_pod_completion decides whether it still has to wait for the base container with self.base_container_name not in self.container_logs. container_logs accepts a single container name as a plain string, and that is also the default ("base"), so for string values this is a substring check rather than a membership check. Any name that merely contains the base container name, such as a typo like "base2" or a sidecar named "base-metrics", makes the operator believe the base container's logs are being followed and skip await_container_completion.

With do_xcom_push=True the operator then execs into the XCom sidecar while the base container is still running, reads an empty return.json, tears the sidecar down, and the task succeeds with a None XCom. Nothing is logged as an error, so downstream tasks silently receive wrong data.

What

  • providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py: normalise a string container_logs into a single-element list before the membership check in await_pod_completion, so the base container is awaited whenever its logs are not actually being followed. Behaviour for True and list values is unchanged.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Fable 5.1)

When container_logs is a single container name, the check that decides
whether the base container still needs to be awaited used `in` on a
string, which is a substring match. Any name containing the base
container name (a typo like "base2", or a sidecar like "base-metrics")
made the operator believe the base container's logs were being followed
and skip the explicit wait. XCom extraction then ran while the base
container was still running, read an empty result, tore down the
sidecar, and the task succeeded with a None XCom.
@boring-cyborg boring-cyborg Bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Sep 4, 2026
@henry3260 henry3260 added the ready for maintainer review Set after triaging when all criteria pass. label Sep 5, 2026
@potiuk
potiuk merged commit 72f6173 into apache:main Sep 8, 2026
108 checks passed
@henry3260
henry3260 deleted the fix-kpo-container-logs-substring-match branch September 8, 2026 22:46
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…pache#72502)

When container_logs is a single container name, the check that decides
whether the base container still needs to be awaited used `in` on a
string, which is a substring match. Any name containing the base
container name (a typo like "base2", or a sidecar like "base-metrics")
made the operator believe the base container's logs were being followed
and skip the explicit wait. XCom extraction then ran while the base
container was still running, read an empty result, tore down the
sidecar, and the task succeeded with a None XCom.
regarmukesh3g pushed a commit to regarmukesh3g/airflow that referenced this pull request Sep 27, 2026
…pache#72502)

When container_logs is a single container name, the check that decides
whether the base container still needs to be awaited used `in` on a
string, which is a substring match. Any name containing the base
container name (a typo like "base2", or a sidecar like "base-metrics")
made the operator believe the base container's logs were being followed
and skip the explicit wait. XCom extraction then ran while the base
container was still running, read an empty result, tore down the
sidecar, and the task succeeded with a None XCom.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants