Fix k8s driver when using in cluster config

We need to catch now the ConfigException like in the reset method to
see if we had no config file.

Change-Id: I648167a40d6e62efc2ab834b89ce49c8efddf974
Story: 2008533
Task: 41619
This commit is contained in:
Tobias Henkel 2021-01-20 19:53:15 +01:00
parent e7f831c34e
commit 90b79dea18
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2

View File

@ -59,7 +59,13 @@ class KubernetesProvider(Provider, QuotaSupport):
self.log.debug("Kubernetes config file not found, attempting " self.log.debug("Kubernetes config file not found, attempting "
"to load in-cluster configs") "to load in-cluster configs")
conf = k8s_config.load_incluster_config() conf = k8s_config.load_incluster_config()
except k8s_config.config_exception.ConfigException as e:
if 'Invalid kube-config file. No configuration found.' in str(e):
self.log.debug("Kubernetes config file not found, attempting "
"to load in-cluster configs")
conf = k8s_config.load_incluster_config()
else:
raise
return ( return (
k8s_client.CoreV1Api(conf), k8s_client.CoreV1Api(conf),
k8s_client.RbacAuthorizationV1beta1Api(conf)) k8s_client.RbacAuthorizationV1beta1Api(conf))