MatthewRBruce commented on a change in pull request #15490:
URL: https://github.com/apache/airflow/pull/15490#discussion_r651273773



##########
File path: airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
##########
@@ -545,17 +544,17 @@ def monitor_launched_pod(self, launcher, pod) -> 
Tuple[State, Optional[str]]:
         :return:
         """
         try:
-            (final_state, result) = launcher.monitor_pod(pod, 
get_logs=self.get_logs)
+            (final_state, pod_info, result) = launcher.monitor_pod(pod, 
get_logs=self.get_logs)
         finally:
             if self.is_delete_operator_pod:
                 launcher.delete_pod(pod)
         if final_state != State.SUCCESS:
             if self.log_events_on_failure:
-                for event in launcher.read_pod_events(pod).items:
+                for event in pod_info.items:

Review comment:
       Ah, that makes sense then.  I was just going over the code and your 
other comments and I wonder if it wouldn't be easier and better to re-read the 
pod like `self.pod = launcher.read_pod(self.pod)` in the `finally` blocks of 
`monitor_launched_pod` and `create_new_pod_for_operator`:
   
https://github.com/apache/airflow/blob/main/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py#L528
   
https://github.com/apache/airflow/blob/main/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py#L550
   
   and then just log `self.pod` here:
   
https://github.com/apache/airflow/blob/main/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py#L369
   
   Way fewer changes and a lot less passing the pod around through the various 
functions.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to