xvega commented on code in PR #71349:
URL: https://github.com/apache/airflow/pull/71349#discussion_r4056667033


##########
providers/google/src/airflow/providers/google/cloud/hooks/kubernetes_engine.py:
##########
@@ -478,6 +482,27 @@ def apply_from_yaml_file(
         )
 
 
+class _GKEAsyncApiClient(async_client.ApiClient):
+    """Retry a rejected GKE token once with refreshed credentials."""
+
+    def __init__(
+        self,
+        configuration: async_client.Configuration,
+        refresh_token: Callable[[], Awaitable[str | None]],
+    ) -> None:
+        super().__init__(configuration=configuration)
+        self._refresh_token = refresh_token
+
+    async def call_api(self, *args: Any, **kwargs: Any) -> Any:
+        try:
+            return await super().call_api(*args, **kwargs)
+        except async_client.ApiException as error:
+            if error.status != 401:

Review Comment:
   How about following google-auth’s refresh-on-401 approach, capped at one 
attempt? I’d retry only if the token changes and propagate any refresh or retry 
failure. This preserves the refresh attempt requested by @soupam05 



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