@@ -224,31 +224,7 @@ def up(self):
224
224
body = aw ,
225
225
)
226
226
else :
227
- with open (self .app_wrapper_yaml ) as f :
228
- yamls = yaml .load_all (f , Loader = yaml .FullLoader )
229
- for resource in yamls :
230
- if resource ["kind" ] == "RayCluster" :
231
- api_instance .create_namespaced_custom_object (
232
- group = "ray.io" ,
233
- version = "v1alpha1" ,
234
- namespace = namespace ,
235
- plural = "rayclusters" ,
236
- body = resource ,
237
- )
238
- elif resource ["kind" ] == "Route" :
239
- api_instance .create_namespaced_custom_object (
240
- group = "route.openshift.io" ,
241
- version = "v1" ,
242
- namespace = namespace ,
243
- plural = "routes" ,
244
- body = resource ,
245
- )
246
- elif resource ["kind" ] == "Secret" :
247
- secret_instance = client .CoreV1Api (api_config_handler ())
248
- secret_instance .create_namespaced_secret (
249
- namespace = namespace ,
250
- body = resource ,
251
- )
227
+ self ._component_level_up (namespace , api_instance )
252
228
except Exception as e : # pragma: no cover
253
229
return _kube_api_error_handling (e )
254
230
@@ -270,33 +246,7 @@ def down(self):
270
246
name = self .app_wrapper_name ,
271
247
)
272
248
else :
273
- with open (self .app_wrapper_yaml ) as f :
274
- yamls = yaml .load_all (f , Loader = yaml .FullLoader )
275
- for resource in yamls :
276
- if resource ["kind" ] == "RayCluster" :
277
- api_instance .delete_namespaced_custom_object (
278
- group = "ray.io" ,
279
- version = "v1alpha1" ,
280
- namespace = namespace ,
281
- plural = "rayclusters" ,
282
- name = self .app_wrapper_name ,
283
- )
284
- elif resource ["kind" ] == "Route" :
285
- name = resource ["metadata" ]["name" ]
286
- api_instance .delete_namespaced_custom_object (
287
- group = "route.openshift.io" ,
288
- version = "v1" ,
289
- namespace = namespace ,
290
- plural = "routes" ,
291
- name = name ,
292
- )
293
- elif resource ["kind" ] == "Secret" :
294
- name = resource ["metadata" ]["name" ]
295
- secret_instance = client .CoreV1Api (api_config_handler ())
296
- secret_instance .delete_namespaced_secret (
297
- namespace = namespace ,
298
- name = name ,
299
- )
249
+ self ._component_level_down (namespace , api_instance )
300
250
except Exception as e : # pragma: no cover
301
251
return _kube_api_error_handling (e )
302
252
@@ -350,7 +300,10 @@ def status(
350
300
351
301
# check the ray cluster status
352
302
cluster = _ray_cluster_status (self .config .name , self .config .namespace )
353
- if cluster and not cluster .status == RayClusterStatus .UNKNOWN :
303
+ if cluster :
304
+ if cluster .status == RayClusterStatus .UNKNOWN :
305
+ ready = False
306
+ status = CodeFlareClusterStatus .STARTING
354
307
if cluster .status == RayClusterStatus .READY :
355
308
ready = True
356
309
status = CodeFlareClusterStatus .READY
@@ -401,7 +354,7 @@ def wait_ready(self, timeout: Optional[int] = None, dashboard_check: bool = True
401
354
time = 0
402
355
while not ready :
403
356
status , ready = self .status (print_to_console = False )
404
- if self . config . mcad and status == CodeFlareClusterStatus .UNKNOWN :
357
+ if status == CodeFlareClusterStatus .UNKNOWN :
405
358
print (
406
359
"WARNING: Current cluster status is unknown, have you run cluster.up yet?"
407
360
)
@@ -548,6 +501,66 @@ def local_client_url(self):
548
501
else :
549
502
return "None"
550
503
504
+ def _component_level_up (
505
+ self , namespace : str , api_instance : client .CustomObjectsApi
506
+ ):
507
+ with open (self .app_wrapper_yaml ) as f :
508
+ yamls = yaml .load_all (f , Loader = yaml .FullLoader )
509
+ for resource in yamls :
510
+ if resource ["kind" ] == "RayCluster" :
511
+ api_instance .create_namespaced_custom_object (
512
+ group = "ray.io" ,
513
+ version = "v1alpha1" ,
514
+ namespace = namespace ,
515
+ plural = "rayclusters" ,
516
+ body = resource ,
517
+ )
518
+ elif resource ["kind" ] == "Route" :
519
+ api_instance .create_namespaced_custom_object (
520
+ group = "route.openshift.io" ,
521
+ version = "v1" ,
522
+ namespace = namespace ,
523
+ plural = "routes" ,
524
+ body = resource ,
525
+ )
526
+ elif resource ["kind" ] == "Secret" :
527
+ secret_instance = client .CoreV1Api (api_config_handler ())
528
+ secret_instance .create_namespaced_secret (
529
+ namespace = namespace ,
530
+ body = resource ,
531
+ )
532
+
533
+ def _component_level_down (
534
+ self , namespace : str , api_instance : client .CustomObjectsApi
535
+ ):
536
+ with open (self .app_wrapper_yaml ) as f :
537
+ yamls = yaml .load_all (f , Loader = yaml .FullLoader )
538
+ for resource in yamls :
539
+ if resource ["kind" ] == "RayCluster" :
540
+ api_instance .delete_namespaced_custom_object (
541
+ group = "ray.io" ,
542
+ version = "v1alpha1" ,
543
+ namespace = namespace ,
544
+ plural = "rayclusters" ,
545
+ name = self .app_wrapper_name ,
546
+ )
547
+ elif resource ["kind" ] == "Route" :
548
+ name = resource ["metadata" ]["name" ]
549
+ api_instance .delete_namespaced_custom_object (
550
+ group = "route.openshift.io" ,
551
+ version = "v1" ,
552
+ namespace = namespace ,
553
+ plural = "routes" ,
554
+ name = name ,
555
+ )
556
+ elif resource ["kind" ] == "Secret" :
557
+ name = resource ["metadata" ]["name" ]
558
+ secret_instance = client .CoreV1Api (api_config_handler ())
559
+ secret_instance .delete_namespaced_secret (
560
+ namespace = namespace ,
561
+ name = name ,
562
+ )
563
+
551
564
552
565
def list_all_clusters (namespace : str , print_to_console : bool = True ):
553
566
"""
0 commit comments