From 392a8c1d0767ce534b121b3b0553e5b1297e430e Mon Sep 17 00:00:00 2001 From: Alexis Zamanis Date: Thu, 10 Nov 2022 11:44:44 +0200 Subject: [PATCH] Improve the refreshing of tokens from inside the cluster Requests from inside the cluster misuse the API to refresh tokens. Signed-off-by: Alexis Zamanis --- kubernetes/base/config/incluster_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kubernetes/base/config/incluster_config.py b/kubernetes/base/config/incluster_config.py index 5dabd4b7cc..86070df43b 100644 --- a/kubernetes/base/config/incluster_config.py +++ b/kubernetes/base/config/incluster_config.py @@ -92,12 +92,12 @@ def _set_config(self, client_configuration): if not self._try_refresh_token: return - def load_token_from_file(*args): + def _refresh_api_key(client_configuration): if self.token_expires_at <= datetime.datetime.now(): self._read_token_file() - return self.token + self._set_config(client_configuration) - client_configuration.get_api_key_with_prefix = load_token_from_file + client_configuration.refresh_api_key_hook = _refresh_api_key def _read_token_file(self): with open(self._token_filename) as f: