|
38 | 38 | from kubernetes import client, config
|
39 | 39 | import yaml
|
40 | 40 | import os
|
| 41 | +import requests |
41 | 42 |
|
42 | 43 |
|
43 | 44 | class Cluster:
|
@@ -217,27 +218,38 @@ def status(
|
217 | 218 |
|
218 | 219 | return status, ready
|
219 | 220 |
|
| 221 | + def is_dashboard_ready(self) -> bool: |
| 222 | + try: |
| 223 | + response = requests.get(self.cluster_dashboard_uri(), timeout=5) |
| 224 | + if response.status_code == 200: |
| 225 | + return True |
| 226 | + except requests.RequestException: |
| 227 | + pass |
| 228 | + return False |
| 229 | + |
220 | 230 | def wait_ready(self, timeout: Optional[int] = None):
|
221 | 231 | """
|
222 | 232 | Waits for requested cluster to be ready, up to an optional timeout (s).
|
223 | 233 | Checks every five seconds.
|
224 | 234 | """
|
225 | 235 | print("Waiting for requested resources to be set up...")
|
226 | 236 | ready = False
|
| 237 | + dashboard_ready = False |
227 | 238 | status = None
|
228 | 239 | time = 0
|
229 |
| - while not ready: |
| 240 | + while not ready or not dashboard_ready: |
230 | 241 | status, ready = self.status(print_to_console=False)
|
| 242 | + dashboard_ready = self.is_dashboard_ready() |
231 | 243 | if status == CodeFlareClusterStatus.UNKNOWN:
|
232 | 244 | print(
|
233 | 245 | "WARNING: Current cluster status is unknown, have you run cluster.up yet?"
|
234 |
| - ) |
235 |
| - if not ready: |
| 246 | + ) |
| 247 | + if not ready or not dashboard_ready: |
236 | 248 | if timeout and time >= timeout:
|
237 | 249 | raise TimeoutError(f"wait() timed out after waiting {timeout}s")
|
238 | 250 | sleep(5)
|
239 | 251 | time += 5
|
240 |
| - print("Requested cluster up and running!") |
| 252 | + print("Requested cluster dashboard are up and running!") |
241 | 253 |
|
242 | 254 | def details(self, print_to_console: bool = True) -> RayCluster:
|
243 | 255 | cluster = _copy_to_ray(self)
|
|
0 commit comments