Skip to content

Commit

Permalink
Merge pull request #2 from stackhpc/feature/wait-for-cluster-services
Browse files Browse the repository at this point in the history
Wait for cluster services to become available
  • Loading branch information
mkjpryor authored Dec 4, 2023
2 parents fa7f349 + bf101ca commit 9157bb4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Azimuth/kubernetes_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,28 @@ def get_kubernetes_cluster_service_url(self, cluster: t.Dict[str, t.Any], name:
"""
Returns the Zenith FQDN for the specified cluster service.
"""
return self.wait_for_kubernetes_cluster_service_url(cluster["id"], name)

@keyword
def wait_for_kubernetes_cluster_service_url(self, id: str, name: str, interval: int = 15) -> str:
"""
Returns the Zenith FQDN for the specified cluster service.
Because the Zenith operator is asynchronous, we wait to see if the services appear.
"""
# Allow some shortcut names
names = {name}
if name in {"dashboard", "kubernetes-dashboard"}:
names.add("kubernetes-dashboard-client")
if name == "monitoring":
names.add("monitoring-system-kube-prometheus-stack-client")
try:
return next(
service["fqdn"]
for service in cluster["services"]
if service["name"] in names
)
except StopIteration:
raise ValueError(f"no such service - {name}")
cluster = util.wait_for_resource(
self._resource,
id,
lambda cluster: any(s["name"] in names for s in cluster["services"]),
interval
)
return next(s["fqdn"] for s in cluster["services"] if s["name"] in names)

@contextlib.contextmanager
def _kubeconfig_for_cluster(self, id: str):
Expand Down

0 comments on commit 9157bb4

Please sign in to comment.