Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #314 from helxplatform/amb-label-selector
Browse files Browse the repository at this point in the history
Use a label selector to identify when ambassador is up in a backwards-compatible way
  • Loading branch information
Hoid authored May 20, 2024
2 parents 480cb1c + 34e22eb commit 6b765a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tycho/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@ def check_volumes(self, volumes, namespace):
logger.debug(f"Raising persistent volume claim exception. {e}")
#raise

def is_ambassador_context(self, namespace):
def is_ambassador_context(self, namespace, ambassador_service_name):
try:
api_response = self.api.list_namespaced_service(field_selector="metadata.name=ambassador", namespace=namespace)
if len(api_response.items) > 0:
return True
else:
return False
field_sel_api_response = self.api.list_namespaced_service(field_selector=f"metadata.name={ambassador_service_name}", namespace=namespace)
return len(field_sel_api_response.items) == 1
except ApiException as e:
logger.info(f"Amabassador is not configured.")
logger.info(f"There was a problem assessing whether the ambassador service is running.", e)

def start (self, system, namespace="default"):
""" Start an abstractly described distributed system on the cluster.
Expand All @@ -119,7 +116,7 @@ def start (self, system, namespace="default"):
systemVolumesCopy.append(value)
system.volumes = systemVolumesCopy
""" Check the status of ambassador """
amb_status = self.is_ambassador_context(namespace)
amb_status = self.is_ambassador_context(namespace, system.ambassador_service_name)
if amb_status:
system.amb = True
#api_response = self.api.list_namespace()
Expand Down
1 change: 1 addition & 0 deletions tycho/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def __init__(self, config, name, principal, service_account, conn_string, proxy_
self.gitea_host = os.environ.get("GITEA_HOST", " ")
self.gitea_user = os.environ.get("GITEA_USER", " ")
self.gitea_service_name = os.environ.get("GITEA_SERVICE_NAME", " ")
self.ambassador_service_name = os.environ.get("AMBASSADOR_SVC_NAME", "")

@staticmethod
def set_security_context(sc_from_registry):
Expand Down

0 comments on commit 6b765a1

Please sign in to comment.