@@ -902,25 +902,47 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
902902 status = RayClusterStatus (rc ["status" ]["state" ].lower ())
903903 else :
904904 status = RayClusterStatus .UNKNOWN
905- try :
906- config_check ()
907- api_instance = client .NetworkingV1Api (api_config_handler ())
908- ingresses = api_instance .list_namespaced_ingress (rc ["metadata" ]["namespace" ])
909- except Exception as e : # pragma no cover
910- return _kube_api_error_handling (e )
911- ray_ingress = None
912- for ingress in ingresses .items :
913- annotations = ingress .metadata .annotations
914- protocol = "http"
915- if (
916- ingress .metadata .name == f"ray-dashboard-{ rc ['metadata' ]['name' ]} "
917- or ingress .metadata .name .startswith (f"{ rc ['metadata' ]['name' ]} -ingress" )
918- ):
919- if annotations == None :
920- protocol = "http"
921- elif "route.openshift.io/termination" in annotations :
922- protocol = "https"
923- ray_ingress = f"{ protocol } ://{ ingress .spec .rules [0 ].host } "
905+ config_check ()
906+ dashboard_url = None
907+ if is_openshift_cluster ():
908+ try :
909+ api_instance = client .CustomObjectsApi (api_config_handler ())
910+ routes = api_instance .list_namespaced_custom_object (
911+ group = "route.openshift.io" ,
912+ version = "v1" ,
913+ namespace = rc ["metadata" ]["namespace" ],
914+ plural = "routes" ,
915+ )
916+ except Exception as e : # pragma: no cover
917+ return _kube_api_error_handling (e )
918+
919+ for route in routes ["items" ]:
920+ rc_name = rc ["metadata" ]["name" ]
921+ if route ["metadata" ]["name" ] == f"ray-dashboard-{ rc_name } " or route [
922+ "metadata"
923+ ]["name" ].startswith (f"{ rc_name } -ingress" ):
924+ protocol = "https" if route ["spec" ].get ("tls" ) else "http"
925+ dashboard_url = f"{ protocol } ://{ route ['spec' ]['host' ]} "
926+ else :
927+ try :
928+ api_instance = client .NetworkingV1Api (api_config_handler ())
929+ ingresses = api_instance .list_namespaced_ingress (
930+ rc ["metadata" ]["namespace" ]
931+ )
932+ except Exception as e : # pragma no cover
933+ return _kube_api_error_handling (e )
934+ for ingress in ingresses .items :
935+ annotations = ingress .metadata .annotations
936+ protocol = "http"
937+ if (
938+ ingress .metadata .name == f"ray-dashboard-{ rc ['metadata' ]['name' ]} "
939+ or ingress .metadata .name .startswith (f"{ rc ['metadata' ]['name' ]} -ingress" )
940+ ):
941+ if annotations == None :
942+ protocol = "http"
943+ elif "route.openshift.io/termination" in annotations :
944+ protocol = "https"
945+ dashboard_url = f"{ protocol } ://{ ingress .spec .rules [0 ].host } "
924946
925947 return RayCluster (
926948 name = rc ["metadata" ]["name" ],
@@ -947,7 +969,7 @@ def _map_to_ray_cluster(rc) -> Optional[RayCluster]:
947969 head_gpu = rc ["spec" ]["headGroupSpec" ]["template" ]["spec" ]["containers" ][0 ][
948970 "resources"
949971 ]["limits" ]["nvidia.com/gpu" ],
950- dashboard = ray_ingress ,
972+ dashboard = dashboard_url ,
951973 )
952974
953975
0 commit comments