MatthewRBruce commented on a change in pull request #7292: [AIRFLOW-6678] Pull 
event logs from Kubernetes pod on failure
URL: https://github.com/apache/airflow/pull/7292#discussion_r374166065
 
 

 ##########
 File path: airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py
 ##########
 @@ -277,11 +281,19 @@ def execute(self, context):
                     pod,
                     startup_timeout=self.startup_timeout_seconds,
                     get_logs=self.get_logs)
+            except AirflowException:
+                if self.log_events_on_failure:
+                    for event in launcher.read_pod_events(pod).items:
+                        self.log.error("Pod Event: %s - %s", event.reason, 
event.message)
+                raise
             finally:
                 if self.is_delete_operator_pod:
                     launcher.delete_pod(pod)
 
             if final_state != State.SUCCESS:
+                if self.log_events_on_failure:
 
 Review comment:
   If we hit an exception at lines 285-288, we would log the pod events, then 
re-raise the exception which shouldn't allow execution to the logging at lines 
294-296 - so I don't think it's possible to log them twice - unless I'm missing 
something here, I haven't had coffee yet :)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to