SameerMesiah97 commented on code in PR #60532:
URL: https://github.com/apache/airflow/pull/60532#discussion_r2724052606


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -816,48 +816,54 @@ def __init__(
         self.config_dict = config_dict
         self._extras: dict | None = connection_extras
         self._event_polling_fallback = False
+        self._config_loaded = False
 
     async def _load_config(self):
-        """Return Kubernetes API session for use with requests."""
+        """Load Kubernetes configuration once per hook instance."""
+        if self._config_loaded:
+            return
+
         in_cluster = self._coalesce_param(self.in_cluster, await 
self._get_field("in_cluster"))
         cluster_context = self._coalesce_param(self.cluster_context, await 
self._get_field("cluster_context"))
         kubeconfig_path = await self._get_field("kube_config_path")
         kubeconfig = await self._get_field("kube_config")
+
         num_selected_configuration = sum(
             1 for o in [in_cluster, kubeconfig, kubeconfig_path, 
self.config_dict] if o
         )
 
-        async def api_client_from_kubeconfig_file(_kubeconfig_path: str | 
None):
-            await async_config.load_kube_config(
-                config_file=_kubeconfig_path,
-                client_configuration=self.client_configuration,
-                context=cluster_context,
-            )
-            return _TimeoutAsyncK8sApiClient()
-
         if num_selected_configuration > 1:
             raise AirflowException(
                 "Invalid connection configuration. Options kube_config_path, "
-                "kube_config, in_cluster are mutually exclusive. "
+                "kube_config, in_cluster, and config_dict are mutually 
exclusive. "
                 "You can only use one option at a time."
             )
 
         if in_cluster:
             self.log.debug(LOADING_KUBE_CONFIG_FILE_RESOURCE.format("within a 
pod"))
-            self._is_in_cluster = True
             async_config.load_incluster_config()
-            return _TimeoutAsyncK8sApiClient()
+            self._is_in_cluster = True

Review Comment:
   `self._is_in_cluster` is already present in the existing code. I just moved 
it after `async_config.load_incluster_config()` and git is interpreting that as 
a new line being removed and added. 



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