@@ -60,7 +60,9 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
60
60
61
61
from .auth import config_check, api_config_handler
62
62
from ..utils import pretty_print
63
- from ..utils.generate_yaml import generate_appwrapper
63
+ from ..utils.generate_yaml import (
64
+ generate_appwrapper,
65
+ )
64
66
from ..utils.kube_api_helpers import _kube_api_error_handling
65
67
from ..utils.openshift_oauth import (
66
68
create_openshift_oauth_objects,
@@ -207,6 +209,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
207
209
local_interactive = self.config.local_interactive
208
210
image_pull_secrets = self.config.image_pull_secrets
209
211
dispatch_priority = self.config.dispatch_priority
212
+ ingress_domain = self.config.ingress_domain
213
+ ingress_options = self.config.ingress_options
210
214
return generate_appwrapper(
211
215
name=name,
212
216
namespace=namespace,
@@ -230,6 +234,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
230
234
dispatch_priority=dispatch_priority,
231
235
priority_val=priority_val,
232
236
openshift_oauth=self.config.openshift_oauth,
237
+ ingress_domain=ingress_domain,
238
+ ingress_options=ingress_options,
233
239
)
234
240
235
241
# creates a new cluster with the provided or default spec
@@ -368,7 +374,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
368
374
timeout=5,
369
375
verify=self._client_verify_tls,
370
376
)
371
- except requests.exceptions.SSLError:
377
+ except requests.exceptions.SSLError: # pragma no cover
372
378
# SSL exception occurs when oauth ingress has been created but cluster is not up
373
379
return False
374
380
if response.status_code == 200:
@@ -431,27 +437,24 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
431
437
"""
432
438
try:
433
439
config_check()
434
- api_instance = client.CustomObjectsApi(api_config_handler())
435
- routes = api_instance.list_namespaced_custom_object(
436
- group="route.openshift.io",
437
- version="v1",
438
- namespace=self.config.namespace,
439
- plural="routes",
440
- )
441
- except Exception as e: # pragma: no cover
440
+ api_instance = client.NetworkingV1Api(api_config_handler())
441
+ ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
442
+ except Exception as e: # pragma no cover
442
443
return _kube_api_error_handling(e)
443
444
444
- for route in routes["items"]:
445
- if route["metadata"][
446
- "name"
447
- ] == f"ray-dashboard-{self.config.name}" or route["metadata"][
448
- "name"
449
- ].startswith(
450
- f"{self.config.name}-ingress"
445
+ for ingress in ingresses.items:
446
+ annotations = ingress.metadata.annotations
447
+ protocol = "http"
448
+ if (
449
+ ingress.metadata.name == f"ray-dashboard-{self.config.name}"
450
+ or ingress.metadata.name.startswith(f"{self.config.name}-ingress")
451
451
):
452
- protocol = "https" if route["spec"].get("tls") else "http"
453
- return f"{protocol}://{route['spec']['host']}"
454
- return "Dashboard route not available yet, have you run cluster.up()?"
452
+ if annotations == None:
453
+ protocol = "http"
454
+ elif "route.openshift.io/termination" in annotations:
455
+ protocol = "https"
456
+ return f"{protocol}://{ingress.spec.rules[0].host}"
457
+ return "Dashboard ingress not available yet, have you run cluster.up()?"
455
458
456
459
def list_jobs(self) -> List:
457
460
"""
@@ -530,8 +533,8 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
530
533
531
534
def local_client_url(self):
532
535
if self.config.local_interactive == True:
533
- ingress_domain = _get_ingress_domain()
534
- return f"ray://rayclient-{self.config.name}-{self.config.namespace}. {ingress_domain}"
536
+ ingress_domain = _get_ingress_domain(self )
537
+ return f"ray://{ingress_domain}"
535
538
else:
536
539
return "None"
537
540
@@ -687,16 +690,23 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
687
690
return False
688
691
689
692
690
- def _get_ingress_domain():
693
+ # Cant test this until get_current_namespace is fixed
694
+ def _get_ingress_domain(self): # pragma: no cover
691
695
try:
692
696
config_check()
693
- api_client = client.CustomObjectsApi(api_config_handler())
694
- ingress = api_client.get_cluster_custom_object(
695
- "config.openshift.io", "v1", "ingresses", "cluster"
696
- )
697
+ api_client = client.NetworkingV1Api(api_config_handler())
698
+ if self.config.namespace != None:
699
+ namespace = self.config.namespace
700
+ else:
701
+ namespace = get_current_namespace()
702
+ ingresses = api_client.list_namespaced_ingress(namespace)
697
703
except Exception as e: # pragma: no cover
698
704
return _kube_api_error_handling(e)
699
- return ingress["spec"]["domain"]
705
+ domain = None
706
+ for ingress in ingresses.items:
707
+ if ingress.spec.rules[0].http.paths[0].backend.service.port.number == 10001:
708
+ domain = ingress.spec.rules[0].host
709
+ return domain
700
710
701
711
702
712
def _app_wrapper_status(name, namespace="default") -> Optional[AppWrapper]:
@@ -788,27 +798,25 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
788
798
status = RayClusterStatus(rc["status"]["state"].lower())
789
799
else:
790
800
status = RayClusterStatus.UNKNOWN
791
-
792
- config_check()
793
- api_instance = client.CustomObjectsApi(api_config_handler())
794
- # UPDATE THIS
795
- routes = api_instance.list_namespaced_custom_object(
796
- group="route.openshift.io",
797
- version="v1",
798
- namespace=rc["metadata"]["namespace"],
799
- plural="routes",
800
- )
801
- ray_route = None
802
- for route in routes["items"]:
803
- if route["metadata"][
804
- "name"
805
- ] == f"ray-dashboard-{rc['metadata']['name']}" or route["metadata"][
806
- "name"
807
- ].startswith(
808
- f"{rc['metadata']['name']}-ingress"
801
+ try:
802
+ config_check()
803
+ api_instance = client.NetworkingV1Api(api_config_handler())
804
+ ingresses = api_instance.list_namespaced_ingress(rc["metadata"]["namespace"])
805
+ except Exception as e: # pragma no cover
806
+ return _kube_api_error_handling(e)
807
+ ray_ingress = None
808
+ for ingress in ingresses.items:
809
+ annotations = ingress.metadata.annotations
810
+ protocol = "http"
811
+ if (
812
+ ingress.metadata.name == f"ray-dashboard-{rc['metadata']['name']}"
813
+ or ingress.metadata.name.startswith(f"{rc['metadata']['name']}-ingress")
809
814
):
810
- protocol = "https" if route["spec"].get("tls") else "http"
811
- ray_route = f"{protocol}://{route['spec']['host']}"
815
+ if annotations == None:
816
+ protocol = "http"
817
+ elif "route.openshift.io/termination" in annotations:
818
+ protocol = "https"
819
+ ray_ingress = f"{protocol}://{ingress.spec.rules[0].host}"
812
820
813
821
return RayCluster(
814
822
name=rc["metadata"]["name"],
@@ -826,7 +834,6 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
826
834
]["resources"]["limits"]["cpu"],
827
835
worker_gpu=0, # hard to detect currently how many gpus, can override it with what the user asked for
828
836
namespace=rc["metadata"]["namespace"],
829
- dashboard=ray_route,
830
837
head_cpus=rc["spec"]["headGroupSpec"]["template"]["spec"]["containers"][0][
831
838
"resources"
832
839
]["limits"]["cpu"],
@@ -836,6 +843,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.cluster</code></h1>
836
843
head_gpu=rc["spec"]["headGroupSpec"]["template"]["spec"]["containers"][0][
837
844
"resources"
838
845
]["limits"]["nvidia.com/gpu"],
846
+ dashboard=ray_ingress,
839
847
)
840
848
841
849
@@ -1136,6 +1144,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1136
1144
local_interactive = self.config.local_interactive
1137
1145
image_pull_secrets = self.config.image_pull_secrets
1138
1146
dispatch_priority = self.config.dispatch_priority
1147
+ ingress_domain = self.config.ingress_domain
1148
+ ingress_options = self.config.ingress_options
1139
1149
return generate_appwrapper(
1140
1150
name=name,
1141
1151
namespace=namespace,
@@ -1159,6 +1169,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1159
1169
dispatch_priority=dispatch_priority,
1160
1170
priority_val=priority_val,
1161
1171
openshift_oauth=self.config.openshift_oauth,
1172
+ ingress_domain=ingress_domain,
1173
+ ingress_options=ingress_options,
1162
1174
)
1163
1175
1164
1176
# creates a new cluster with the provided or default spec
@@ -1297,7 +1309,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1297
1309
timeout=5,
1298
1310
verify=self._client_verify_tls,
1299
1311
)
1300
- except requests.exceptions.SSLError:
1312
+ except requests.exceptions.SSLError: # pragma no cover
1301
1313
# SSL exception occurs when oauth ingress has been created but cluster is not up
1302
1314
return False
1303
1315
if response.status_code == 200:
@@ -1360,27 +1372,24 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1360
1372
"""
1361
1373
try:
1362
1374
config_check()
1363
- api_instance = client.CustomObjectsApi(api_config_handler())
1364
- routes = api_instance.list_namespaced_custom_object(
1365
- group="route.openshift.io",
1366
- version="v1",
1367
- namespace=self.config.namespace,
1368
- plural="routes",
1369
- )
1370
- except Exception as e: # pragma: no cover
1375
+ api_instance = client.NetworkingV1Api(api_config_handler())
1376
+ ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
1377
+ except Exception as e: # pragma no cover
1371
1378
return _kube_api_error_handling(e)
1372
1379
1373
- for route in routes["items"]:
1374
- if route["metadata"][
1375
- "name"
1376
- ] == f"ray-dashboard-{self.config.name}" or route["metadata"][
1377
- "name"
1378
- ].startswith(
1379
- f"{self.config.name}-ingress"
1380
+ for ingress in ingresses.items:
1381
+ annotations = ingress.metadata.annotations
1382
+ protocol = "http"
1383
+ if (
1384
+ ingress.metadata.name == f"ray-dashboard-{self.config.name}"
1385
+ or ingress.metadata.name.startswith(f"{self.config.name}-ingress")
1380
1386
):
1381
- protocol = "https" if route["spec"].get("tls") else "http"
1382
- return f"{protocol}://{route['spec']['host']}"
1383
- return "Dashboard route not available yet, have you run cluster.up()?"
1387
+ if annotations == None:
1388
+ protocol = "http"
1389
+ elif "route.openshift.io/termination" in annotations:
1390
+ protocol = "https"
1391
+ return f"{protocol}://{ingress.spec.rules[0].host}"
1392
+ return "Dashboard ingress not available yet, have you run cluster.up()?"
1384
1393
1385
1394
def list_jobs(self) -> List:
1386
1395
"""
@@ -1459,8 +1468,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
1459
1468
1460
1469
def local_client_url(self):
1461
1470
if self.config.local_interactive == True:
1462
- ingress_domain = _get_ingress_domain()
1463
- return f"ray://rayclient-{self.config.name}-{self.config.namespace}. {ingress_domain}"
1471
+ ingress_domain = _get_ingress_domain(self )
1472
+ return f"ray://{ingress_domain}"
1464
1473
else:
1465
1474
return "None"
1466
1475
@@ -1580,27 +1589,24 @@ <h3>Methods</h3>
1580
1589
"""
1581
1590
try:
1582
1591
config_check()
1583
- api_instance = client.CustomObjectsApi(api_config_handler())
1584
- routes = api_instance.list_namespaced_custom_object(
1585
- group="route.openshift.io",
1586
- version="v1",
1587
- namespace=self.config.namespace,
1588
- plural="routes",
1589
- )
1590
- except Exception as e: # pragma: no cover
1592
+ api_instance = client.NetworkingV1Api(api_config_handler())
1593
+ ingresses = api_instance.list_namespaced_ingress(self.config.namespace)
1594
+ except Exception as e: # pragma no cover
1591
1595
return _kube_api_error_handling(e)
1592
1596
1593
- for route in routes["items"]:
1594
- if route["metadata"][
1595
- "name"
1596
- ] == f"ray-dashboard-{self.config.name}" or route["metadata"][
1597
- "name"
1598
- ].startswith(
1599
- f"{self.config.name}-ingress"
1597
+ for ingress in ingresses.items:
1598
+ annotations = ingress.metadata.annotations
1599
+ protocol = "http"
1600
+ if (
1601
+ ingress.metadata.name == f"ray-dashboard-{self.config.name}"
1602
+ or ingress.metadata.name.startswith(f"{self.config.name}-ingress")
1600
1603
):
1601
- protocol = "https" if route["spec"].get("tls") else "http"
1602
- return f"{protocol}://{route['spec']['host']}"
1603
- return "Dashboard route not available yet, have you run cluster.up()?"</ code > </ pre >
1604
+ if annotations == None:
1605
+ protocol = "http"
1606
+ elif "route.openshift.io/termination" in annotations:
1607
+ protocol = "https"
1608
+ return f"{protocol}://{ingress.spec.rules[0].host}"
1609
+ return "Dashboard ingress not available yet, have you run cluster.up()?"</ code > </ pre >
1604
1610
</ details >
1605
1611
</ dd >
1606
1612
< dt id ="codeflare_sdk.cluster.cluster.Cluster.cluster_uri "> < code class ="name flex ">
@@ -1678,6 +1684,8 @@ <h3>Methods</h3>
1678
1684
local_interactive = self.config.local_interactive
1679
1685
image_pull_secrets = self.config.image_pull_secrets
1680
1686
dispatch_priority = self.config.dispatch_priority
1687
+ ingress_domain = self.config.ingress_domain
1688
+ ingress_options = self.config.ingress_options
1681
1689
return generate_appwrapper(
1682
1690
name=name,
1683
1691
namespace=namespace,
@@ -1701,6 +1709,8 @@ <h3>Methods</h3>
1701
1709
dispatch_priority=dispatch_priority,
1702
1710
priority_val=priority_val,
1703
1711
openshift_oauth=self.config.openshift_oauth,
1712
+ ingress_domain=ingress_domain,
1713
+ ingress_options=ingress_options,
1704
1714
)</ code > </ pre >
1705
1715
</ details >
1706
1716
</ dd >
@@ -1858,7 +1868,7 @@ <h3>Methods</h3>
1858
1868
timeout=5,
1859
1869
verify=self._client_verify_tls,
1860
1870
)
1861
- except requests.exceptions.SSLError:
1871
+ except requests.exceptions.SSLError: # pragma no cover
1862
1872
# SSL exception occurs when oauth ingress has been created but cluster is not up
1863
1873
return False
1864
1874
if response.status_code == 200:
@@ -1926,8 +1936,8 @@ <h3>Methods</h3>
1926
1936
</ summary >
1927
1937
< pre > < code class ="python "> def local_client_url(self):
1928
1938
if self.config.local_interactive == True:
1929
- ingress_domain = _get_ingress_domain()
1930
- return f"ray://rayclient-{self.config.name}-{self.config.namespace}. {ingress_domain}"
1939
+ ingress_domain = _get_ingress_domain(self )
1940
+ return f"ray://{ingress_domain}"
1931
1941
else:
1932
1942
return "None"</ code > </ pre >
1933
1943
</ details >
0 commit comments