Crowiant commented on code in PR #59097:
URL: https://github.com/apache/airflow/pull/59097#discussion_r2673872633


##########
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:
   No, because .get("creation_timestamp", 
datetime.datetime.now(tz=datetime.timezone.utc) will return datetime.now only 
in case when creation_timestamp field is not presented in the metadata. For 
this cases else statement in the line 1401 was added. 



-- 
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]

Reply via email to