From 4a1167423e37ec2aa4c729b1286525e8b74aa2c9 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 154f291f..10f7dda8 100644 --- a/openshift/dynamic/client.py +++ b/openshift/dynamic/client.py @@ -598,8 +598,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()