cruseakshay commented on code in PR #60626:
URL: https://github.com/apache/airflow/pull/60626#discussion_r2707074126


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -208,8 +209,28 @@ class PodLaunchTimeoutException(AirflowException):
     """When pod does not leave the ``Pending`` phase within specified 
timeout."""
 
 
-class PodNotFoundException(AirflowException):
-    """Expected pod does not exist in kube-api."""
+@dataclass
+class PodPhaseTracker:
+    """
+    Track whether a pod ever reached Running state for safe 404 retry handling.
+
+    If pod never reached Running: safe to retry (likely preemption).
+    If pod was Running: NOT safe to retry (may cause duplicate execution).
+    """
+
+    ever_reached_running: bool = False
+    last_observed_phase: str | None = None
+
+    def update_from_pod(self, pod: V1Pod) -> None:
+        """Update tracker state from observed pod status."""
+        if pod.status and pod.status.phase:
+            self.last_observed_phase = pod.status.phase
+            if pod.status.phase == PodPhase.RUNNING:
+                self.ever_reached_running = True

Review Comment:
   for pods running very quickly, (Pending → Running → Succeeded/Failed),
   ```
   if pod.status.phase in (PodPhase.RUNNING, PodPhase.SUCCEEDED, 
PodPhase.FAILED):
               self.ever_started_execution = True
   ```
   with this we can safely consider, any phase beyond Pending means pod was 
scheduled and not preempted.



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