Skip to content

Commit

Permalink
Merge pull request nusdbsystem#68 from naili-xing/dev
Browse files Browse the repository at this point in the history
fix the issue  nusdbsystem#67
  • Loading branch information
NLGithubWP authored May 25, 2020
2 parents 3f68f29 + 3efbff5 commit f90e122
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions singa_auto/container/kubernetes_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
logger = logging.getLogger(__name__)


class ServiceRequestError(Exception):
pass


class KubernetesContainerManager(ContainerManager):

def __init__(self, **kwargs):
Expand Down Expand Up @@ -87,9 +91,27 @@ def update_ingress(self, ingress_name: str, ingress_body: dict):
)
)

self.api_instance.replace_namespaced_ingress_with_http_info(name=ingress_name,
namespace='default',
body=body)
# check the current ingress list
ingress_list = self.api_instance.list_namespaced_ingress_with_http_info(namespace='default')

if ingress_list[1] != 200:
raise ServiceRequestError("ingress response code is not 200")

# get the ingress name of each ingress
ingress_names = [ele.metadata.name for ele in ingress_list[0].items]

# check if the ingress_name in the list
if ingress_name in ingress_names:

# if the ingress is exist, update it
self.api_instance.replace_namespaced_ingress_with_http_info(name=ingress_name,
namespace='default',
body=body)
else:
# otherwise, create new one
self.api_instance.create_namespaced_ingress_with_http_info(name=ingress_name,
namespace='default',
body=body)

def _update_ingress_paths(self, ingress_body: dict) -> list:
paths = list()
Expand Down

0 comments on commit f90e122

Please sign in to comment.