johnhoran commented on code in PR #61778:
URL: https://github.com/apache/airflow/pull/61778#discussion_r2821725237


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -188,19 +188,43 @@ def detect_pod_terminate_early_issues(pod: V1Pod) -> str 
| None:
     """
     Identify issues that justify terminating the pod early.
 
+    This method distinguishes between permanent failures (e.g., invalid image 
names)
+    and transient errors (e.g., rate limits) that should be retried by 
Kubernetes.
+
     :param pod: The pod object to check.
     :return: An error message if an issue is detected; otherwise, None.
     """
+    # Indicators in error messages that suggest transient issues
+    TRANSIENT_ERROR_PATTERNS = [
+        "pull qps exceeded",
+        "rate limit",
+        "too many requests",
+        "quota exceeded",
+        "temporarily unavailable",
+        "timeout",
+    ]
+
     pod_status = pod.status
     if pod_status.container_statuses:
         for container_status in pod_status.container_statuses:
             container_state: V1ContainerState = container_status.state
             container_waiting: V1ContainerStateWaiting | None = 
container_state.waiting
-            if container_waiting:
-                if container_waiting.reason in ["ErrImagePull", 
"ImagePullBackOff", "InvalidImageName"]:
+            if not container_waiting:
+                continue
+
+            if container_waiting.reason in ["InvalidImageName", 
"ErrImageNeverPull"]:
+                return (
+                    f"Pod docker image cannot be pulled, unable to start: 
{container_waiting.reason}"
+                    f"\n{container_waiting.message or ''}"
+                )
+
+            if container_waiting.reason in ["ErrImagePull", 
"ImagePullBackOff"]:

Review Comment:
   I added the array.  As for moving it up, I have it below the `if not 
container_waiting:` so I can avoid either indenting the block below or adding 
more conditions to it.  Personally I think it makes the code cleaner.



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