shahar1 commented on code in PR #59097:
URL: https://github.com/apache/airflow/pull/59097#discussion_r2678792511
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -1390,6 +1390,17 @@ def _get_most_recent_pod_index(pod_list:
list[k8s.V1Pod]) -> int:
pod_start_times: list[datetime.datetime] = [
pod.to_dict().get("status").get("start_time") for pod in pod_list
]
+ if not all(pod_start_times):
+ pod_start_times: list[datetime.datetime] = [ # type:
ignore[no-redef]
+ pod_start_time
+ if (
+ pod_start_time := pod.to_dict()
+ .get("metadata", {})
+ .get("creation_timestamp",
datetime.datetime.now(tz=datetime.timezone.utc))
+ )
+ else datetime.datetime.now(tz=datetime.timezone.utc)
Review Comment:
If `creation_timestamp` is not in `metadata`, it will return `datetime.now`
due to the `.get(..., datetime.datetime.now(...)`).` - not due to the `if`.
The `else` statement seems to be unreachable (because the latter `get`
always returns not `None`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]