From f1da48185e724ff9fc49b91ebf0b380eee9462ef Mon Sep 17 00:00:00 2001 From: David Parker Date: Tue, 30 Jun 2026 13:09:40 +0100 Subject: [PATCH] [patch] Fix reloadDynamicClient --- python/src/mas/cli/cli.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/python/src/mas/cli/cli.py b/python/src/mas/cli/cli.py index 1c4c135933..620af8ec4d 100644 --- a/python/src/mas/cli/cli.py +++ b/python/src/mas/cli/cli.py @@ -424,8 +424,24 @@ def reloadDynamicClient(self) -> DynamicClient | None: self._apiClient = ApiClient(configuration=k8s_config) self._dynClient = DynamicClient(self._apiClient) else: - config.load_kube_config() - self._apiClient = ApiClient() + # Determine kubeconfig path to force fresh load + kubeconfig_path = environ.get("KUBECONFIG") + if not kubeconfig_path: + from pathlib import Path + + kubeconfig_path = path.join(Path.home(), ".kube", "config") + + logger.debug(f"Loading kubeconfig from {kubeconfig_path}") + + # Clear any cached configuration to ensure fresh load + Configuration.set_default(None) + + # Load the configuration from the kubeconfig file + config.load_kube_config(config_file=kubeconfig_path) + + # Create new API client with the fresh configuration + k8s_config = Configuration.get_default_copy() + self._apiClient = ApiClient(configuration=k8s_config) self._dynClient = DynamicClient(self._apiClient) return self._dynClient except Exception as e: