Skip to content

Commit

Permalink
Fix "Long-lasting job fails on EKS" (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyZZX committed Jul 24, 2019
1 parent a2052de commit b7c496e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions kubetest/objects/api_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging

from kubernetes.client.rest import ApiException
from kubernetes.config import load_kube_config

from kubetest import condition, utils
from kubetest.manifest import load_file
Expand Down Expand Up @@ -95,23 +96,23 @@ def api_client(self):
Raises:
ValueError: The API version is not supported.
"""
if self._api_client is None:
c = self.api_clients.get(self.version)
# If we didn't find the client in the api_clients dict, use the
# preferred version.
load_kube_config()
c = self.api_clients.get(self.version)
# If we didn't find the client in the api_clients dict, use the
# preferred version.
if c is None:
log.warning(
'unknown version ({}), falling back to preferred version'
.format(self.version)
)
c = self.api_clients.get('preferred')
if c is None:
log.warning(
'unknown version ({}), falling back to preferred version'
.format(self.version)
raise ValueError(
'unknown version specified and no preferred version '
'defined for resource ({})'.format(self.version)
)
c = self.api_clients.get('preferred')
if c is None:
raise ValueError(
'unknown version specified and no preferred version '
'defined for resource ({})'.format(self.version)
)
# If we did find it, initialize that client version.
self._api_client = c()
# If we did find it, initialize that client version.
self._api_client = c()
return self._api_client

def wait_until_ready(self, timeout=None, interval=1, fail_on_api_error=False):
Expand Down

0 comments on commit b7c496e

Please sign in to comment.