amoghrajesh commented on code in PR #39296:
URL: https://github.com/apache/airflow/pull/39296#discussion_r1583092989


##########
tests/providers/cncf/kubernetes/operators/test_pod.py:
##########
@@ -1998,6 +1999,29 @@ def test_async_write_logs_should_execute_successfully(
         else:
             mock_manager.return_value.read_pod_logs.assert_not_called()
 
+    @patch(KUB_OP_PATH.format("post_complete_action"))
+    @patch(KUB_OP_PATH.format("extract_xcom"))
+    @patch(HOOK_CLASS)
+    @patch(KUB_OP_PATH.format("pod_manager"))
+    def test_async_write_logs_handler_api_exception(
+        self, mock_manager, mocked_hook, mock_extract_xcom
+    ):
+        mock_manager.read_pod_logs.return_value = ApiException(status=404)

Review Comment:
   Can you also add for non status of 404? 



##########
airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -766,9 +767,15 @@ def _clean(self, event: dict[str, Any]):
         # Skip await_pod_completion when the event is 'timeout' due to the pod 
can hang
         # on the ErrImagePull or ContainerCreating step and it will never 
complete
         if event["status"] != "timeout":
-            self.pod = self.pod_manager.await_pod_completion(
-                self.pod, istio_enabled, self.base_container_name
-            )
+            try:
+                self.pod = self.pod_manager.await_pod_completion(
+                    self.pod, istio_enabled, self.base_container_name
+                )
+            except ApiException as e:
+                if e.status == 404:
+                    self.pod = None

Review Comment:
   Should we do anything specific here? Like Id add a log 



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