Skip to content

Conversation

@johnhoran
Copy link
Contributor

@johnhoran johnhoran commented Dec 12, 2025

Closes #59366

I noticed the callbacks were just being passed the same log line over and over again. I tried previous versions of the provider, and they all seem to have the same bug, so I think this probably never worked correctly.

I think the best thing to do is have the callback be passed the same message that is passed to the logging call, and additionally to add some extra context, like the container name, timestamp and the pod object. Given that this feature hasn't been working before now, I hope it will be okay to modify how it functions like this. The motivation for passing the pod is that I'm playing around with another PR that sets xcoms in a callback attached in deffered mode, and the pod contains the context necessary to set the xcoms in its labels, and it is also available on the triggerer when running in deferred mode, so passing it can be supported there too.

I've also expanded the test to catch this bug in future.

The cause of the bug was the reuse of the line variable from

line = raw_line.decode("utf-8", errors="backslashreplace")
on
which then gets put into the array after the iteration loop has complete

so it ends up just carrying the same line and putting it back into iteration over and over again.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Dec 12, 2025
@johnhoran johnhoran marked this pull request as ready for review December 12, 2025 16:01
@johnhoran johnhoran marked this pull request as draft December 23, 2025 10:13
@johnhoran johnhoran marked this pull request as ready for review December 23, 2025 11:18
@tatiana
Copy link
Contributor

tatiana commented Dec 31, 2025

Thanks a lot for the reviews, @ephraimbuddy and @vatsrahul1001 !

Just wanted to share that we changed the implementation in Cosmos to use the ones proposed by @johnhoran in an ongoing task astronomer/astronomer-cosmos#2207. We were able to reproduce the problem previously, and I can confirm that after the changes, the behaviour works as expected. I validated them both via integration tests and also by running Airflow and triggering a DAG manually.

@uranusjr uranusjr merged commit c0cbd09 into apache:main Jan 8, 2026
102 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes Pod Operator Callbacks progress_callbacks repeat same line

5 participants