You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/11/22 21:56:19 UTC

[GitHub] [airflow] dstandish opened a new pull request, #27845: Patch "checked" when pod not successful

dstandish opened a new pull request, #27845:
URL: https://github.com/apache/airflow/pull/27845

   In KPO, if pod gets stuck in terminating status, then we might keep reattaching to it.
   


-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] dstandish commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1036786509


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -650,6 +652,8 @@ class _suppress(AbstractContextManager):
 
     The caught exception is also stored on the context manager instance under
     attribute ``exception``.
+
+    :meta private:

Review Comment:
   yeah so ... it's just ... one is "suppress with logging" (with otherwise identical semantics to stdlib suppress) the other is "conditionally use ... suppress with logging" which seemed to me nice from perspective of intelligibility.  rather than mashing into one where, it's entirely diff from stdlib and harder to understand what it's doing.
   
   ALAS, i have merged them, and added a test or two



-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] dstandish commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1036727232


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -472,34 +471,36 @@ def execute(self, context: Context):
         if self.do_xcom_push:
             return result
 
+    def _read_pod_log_events(self, pod, *, reraise=True):
+        """Will fetch and emit events from pod"""
+        with _optionally_suppress(reraise=reraise):
+            for event in self.pod_manager.read_pod_events(pod).items:
+                self.log.error("Pod Event: %s - %s", event.reason, event.message)
+
     def cleanup(self, pod: k8s.V1Pod, remote_pod: k8s.V1Pod):
         pod_phase = remote_pod.status.phase if hasattr(remote_pod, "status") else None
-        if not self.is_delete_operator_pod:
-            with _suppress(Exception):
-                self.patch_already_checked(remote_pod)
+        if pod_phase != PodPhase.SUCCEEDED or not self.is_delete_operator_pod:

Review Comment:
   this is the key change in this PR.
   
   We patch not just if "is delete" but also any time tha pod phase is not successful.
   
   this is to ensure that if the pod takes a long time to get removed (or if it simply failed to start in the first place) that we make sure we don't reattach to it on the retry. 
   
   everything else is drive by refactor / cleanup



-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] dstandish merged pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
dstandish merged PR #27845:
URL: https://github.com/apache/airflow/pull/27845


-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1036728907


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -650,6 +652,8 @@ class _suppress(AbstractContextManager):
 
     The caught exception is also stored on the context manager instance under
     attribute ``exception``.
+
+    :meta private:

Review Comment:
   I was thinking we could do
   
   ```python
   class _optionall_suppress(AbstractContextManager):
       ...
   ```
   
   since a lot of the logic in the class doesn’t really seem relevant now. But it’s OK if you feel this is easier.



-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] dstandish commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1035553932


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -650,6 +652,8 @@ class _suppress(AbstractContextManager):
 
     The caught exception is also stored on the context manager instance under
     attribute ``exception``.
+
+    :meta private:

Review Comment:
   not _needed_ of course, but i think the separation of concerns is helpful.  we could define _suppress inside of _optionally_suppress, but... it's already tested this way so... why bother?  and it's private so it's not increasing backcompat surface area i.e. doesn't really hurt to leave it there IMO.  but you tell me
   



-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1030085561


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -650,6 +652,8 @@ class _suppress(AbstractContextManager):
 
     The caught exception is also stored on the context manager instance under
     attribute ``exception``.
+
+    :meta private:

Review Comment:
   Do we still need `_suppress` to be a standalone class/function, or can we simply merge it into `_optionally_suppress`?



-- 
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: commits-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] dstandish commented on a diff in pull request #27845: Patch "checked" when pod not successful

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #27845:
URL: https://github.com/apache/airflow/pull/27845#discussion_r1036727232


##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -472,34 +471,36 @@ def execute(self, context: Context):
         if self.do_xcom_push:
             return result
 
+    def _read_pod_log_events(self, pod, *, reraise=True):
+        """Will fetch and emit events from pod"""
+        with _optionally_suppress(reraise=reraise):
+            for event in self.pod_manager.read_pod_events(pod).items:
+                self.log.error("Pod Event: %s - %s", event.reason, event.message)
+
     def cleanup(self, pod: k8s.V1Pod, remote_pod: k8s.V1Pod):
         pod_phase = remote_pod.status.phase if hasattr(remote_pod, "status") else None
-        if not self.is_delete_operator_pod:
-            with _suppress(Exception):
-                self.patch_already_checked(remote_pod)
+        if pod_phase != PodPhase.SUCCEEDED or not self.is_delete_operator_pod:

Review Comment:
   this line (the addition of "or pod not successful") is the key change in this PR.
   
   We patch not just if "is delete" but also any time tha pod phase is not successful.
   
   this is to ensure that if the pod takes a long time to get removed (or if it simply failed to start in the first place) that we make sure we don't reattach to it on the retry. 
   
   everything else is drive by refactor / cleanup



-- 
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: commits-unsubscribe@airflow.apache.org

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