You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2024/05/01 04:09:05 UTC

Re: [PR] Refresh properties on KubernetesPodOperator when k8s fails due to token expiration [airflow]

amoghrajesh commented on code in PR #39325:
URL: https://github.com/apache/airflow/pull/39325#discussion_r1585856967


##########
airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -647,6 +646,20 @@ def execute_sync(self, context: Context):
         if self.do_xcom_push:
             return result
 
+    @tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_exponential(max=15), reraise=True)

Review Comment:
   We shouldn't retry for every exception, let us add a `retry=tenacity.retry_if_exception_type(kubernetes.client.exceptions.ApiException)`



##########
airflow/providers/cncf/kubernetes/operators/pod.py:
##########
@@ -647,6 +646,20 @@ def execute_sync(self, context: Context):
         if self.do_xcom_push:
             return result
 
+    @tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_exponential(max=15), reraise=True)
+    def await_container_completion(self, pod: k8s.V1Pod, container_name: str):
+        try:
+            self.pod_manager.await_container_completion(pod=pod, container_name=container_name)
+        except kubernetes.client.exceptions.ApiException as e:
+            if str(e.status) == "401":
+                self._refresh_cached_properties()

Review Comment:
   Lets add a log here as well



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