Allow string conversion to datetime for since_time in KPO logs#65498
Merged
jscheffl merged 3 commits intoapache:mainfrom Apr 21, 2026
Merged
Allow string conversion to datetime for since_time in KPO logs#65498jscheffl merged 3 commits intoapache:mainfrom
jscheffl merged 3 commits intoapache:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends KubernetesPodOperator/PodManager log fetching to handle since_time values provided as ISO-8601 strings by converting them into datetime objects instead of silently falling back to None.
Changes:
- Convert string
since_timevalues to datetimes inPodManager.fetch_container_logs()andKubernetesPodOperator._write_logs(). - Expand unit test coverage for valid datetime, invalid input, and ISO-string
since_timehandling. - Refactor the PodManager since-time test to use
time_machinerather than patchingpendulum.now.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py |
Adds parsing of string since_time and broadens exception handling. |
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py |
Adds parsing of string since_time in _write_logs and catches ValueError. |
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_pod_manager.py |
Adds/updates tests for datetime, invalid, and string since_time scenarios. |
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_pod.py |
Adds a new _write_logs test for string since_time and adjusts invalid-case test wording. |
jscheffl
approved these changes
Apr 21, 2026
Contributor
jscheffl
left a comment
There was a problem hiding this comment.
Cool, thanks for the improvement and rework!
shahar1
added a commit
to shahar1/airflow
that referenced
this pull request
Apr 22, 2026
59 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.
The since_seconds attribute in consume_logs (from class PodManager) and _write_logs (from class KubernetesPodOperator) is converted to None if since_time is not a datetime object. I have introduced code to check whether since_time is a string and convert it to a datetime object if possible instead of None.
This was suggested in PR #65232
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.