From 1a841414659f57f13fc113a163782ba7bdac12ef Mon Sep 17 00:00:00 2001 From: Fabian von Feilitzsch Date: Thu, 14 Mar 2019 14:26:18 -0400 Subject: [PATCH] Prevent cache corruption from preventing the client from initializing --- openshift/dynamic/client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openshift/dynamic/client.py b/openshift/dynamic/client.py index 12b6e6ac..d3b1180e 100644 --- a/openshift/dynamic/client.py +++ b/openshift/dynamic/client.py @@ -599,8 +599,11 @@ def __init_cache(self, refresh=False): self._cache = {} refresh = True else: - with open(self.__cache_file, 'r') as f: - self._cache = json.load(f, cls=cache_decoder(self.client)) + try: + with open(self.__cache_file, 'r') as f: + self._cache = json.load(f, cls=cache_decoder(self.client)) + except Exception: + return self.__init_cache(refresh=True) self._load_server_info() self.discover()