pankajkoti commented on code in PR #37363:
URL: https://github.com/apache/airflow/pull/37363#discussion_r1487373964


##########
airflow/providers/cncf/kubernetes/triggers/pod.py:
##########
@@ -155,18 +155,32 @@ def serialize(self) -> tuple[str, dict[str, Any]]:
             },
         )
 
+    def _get_terminal_event(self, state) -> TriggerEvent:
+        if state == PodPhase.SUCCEEDED:
+            status = "success"
+        else:
+            status = "failed"
+        return TriggerEvent({"status": status, "namespace": 
self.pod_namespace, "name": self.pod_name})
+
     async def run(self) -> AsyncIterator[TriggerEvent]:  # type: 
ignore[override]
         """Get current pod status and yield a TriggerEvent."""
         self.log.info("Checking pod %r in namespace %r.", self.pod_name, 
self.pod_namespace)
         try:
             state = await self._wait_for_pod_start()
             if state in PodPhase.terminal_states:
-                event = TriggerEvent(
-                    {"status": "done", "namespace": self.pod_namespace, 
"pod_name": self.pod_name}
-                )
+                event = self._get_terminal_event(state)
             else:
                 event = await self._wait_for_container_completion()
             yield event
+        except PodLaunchTimeoutException as e:
+            description = self._format_exception_description(e)
+            yield TriggerEvent(
+                {
+                    "status": "timeout",
+                    "error_type": e.__class__.__name__,
+                    "description": description,
+                }
+            )

Review Comment:
   In the _wait_for_pod_start method, we should change
   `start_time = timezone.utcnow()` to `start_time = 
datetime.datetime.now(tz=datetime.timezone.utc)`



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