uranusjr commented on code in PR #30425:
URL: https://github.com/apache/airflow/pull/30425#discussion_r1156397061


##########
airflow/executors/kubernetes_executor.py:
##########
@@ -125,11 +125,22 @@ def run(self) -> None:
 
     def _pod_events(self, kube_client: client.CoreV1Api, query_kwargs: dict):
         watcher = watch.Watch()
-
-        if self.namespace == ALL_NAMESPACES:
-            return watcher.stream(kube_client.list_pod_for_all_namespaces, 
**query_kwargs)
-        else:
-            return watcher.stream(kube_client.list_namespaced_pod, 
self.namespace, **query_kwargs)
+        try:
+            if self.namespace == ALL_NAMESPACES:
+                return watcher.stream(kube_client.list_pod_for_all_namespaces, 
**query_kwargs)
+            else:
+                return watcher.stream(kube_client.list_namespaced_pod, 
self.namespace, **query_kwargs)
+        except ApiException as e:
+            if e.status == 410:  # Resource version is too old
+                if self.namespace == ALL_NAMESPACES:
+                    pods = kube_client.list_pod_for_all_namespaces(watch=False)
+                else:
+                    pods = 
kube_client.list_namespaced_pod(namespace=self.namespace, watch=False)
+                resource_version = pods.metadata.resource_version
+                query_kwargs["resource_version"] = resource_version
+                return self._pod_events(kube_client=kube_client, 
query_kwargs=query_kwargs)
+            else:
+                raise e

Review Comment:
   ```suggestion
                   raise
   ```
   
   Obtains the original traceback



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