|
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: |
@@ -250,27 +251,36 @@ def status( |
250 | 251 |
|
251 | 252 | return status, ready |
252 | 253 |
|
| 254 | + def is_dashboard_ready(self) -> bool: |
| 255 | + response = requests.get(self.cluster_dashboard_uri(), timeout=5) |
| 256 | + if response.status_code == 200: |
| 257 | + return True |
| 258 | + else: |
| 259 | + return False |
| 260 | + |
253 | 261 | def wait_ready(self, timeout: Optional[int] = None): |
254 | 262 | """ |
255 | 263 | Waits for requested cluster to be ready, up to an optional timeout (s). |
256 | 264 | Checks every five seconds. |
257 | 265 | """ |
258 | 266 | print("Waiting for requested resources to be set up...") |
259 | 267 | ready = False |
| 268 | + dashboard_ready = False |
260 | 269 | status = None |
261 | 270 | time = 0 |
262 | | - while not ready: |
| 271 | + while not ready or not dashboard_ready: |
263 | 272 | status, ready = self.status(print_to_console=False) |
| 273 | + dashboard_ready = self.is_dashboard_ready() |
264 | 274 | if status == CodeFlareClusterStatus.UNKNOWN: |
265 | 275 | print( |
266 | 276 | "WARNING: Current cluster status is unknown, have you run cluster.up yet?" |
267 | 277 | ) |
268 | | - if not ready: |
| 278 | + if not ready or not dashboard_ready: |
269 | 279 | if timeout and time >= timeout: |
270 | 280 | raise TimeoutError(f"wait() timed out after waiting {timeout}s") |
271 | 281 | sleep(5) |
272 | 282 | time += 5 |
273 | | - print("Requested cluster up and running!") |
| 283 | + print("Requested cluster and dashboard are up and running!") |
274 | 284 |
|
275 | 285 | def details(self, print_to_console: bool = True) -> RayCluster: |
276 | 286 | cluster = _copy_to_ray(self) |
|
0 commit comments