@@ -176,31 +176,7 @@ def up(self):
176
176
body = aw ,
177
177
)
178
178
else :
179
- with open (self .app_wrapper_yaml ) as f :
180
- yamls = yaml .load_all (f , Loader = yaml .FullLoader )
181
- for resource in yamls :
182
- if resource ["kind" ] == "RayCluster" :
183
- api_instance .create_namespaced_custom_object (
184
- group = "ray.io" ,
185
- version = "v1alpha1" ,
186
- namespace = namespace ,
187
- plural = "rayclusters" ,
188
- body = resource ,
189
- )
190
- elif resource ["kind" ] == "Route" :
191
- api_instance .create_namespaced_custom_object (
192
- group = "route.openshift.io" ,
193
- version = "v1" ,
194
- namespace = namespace ,
195
- plural = "routes" ,
196
- body = resource ,
197
- )
198
- elif resource ["kind" ] == "Secret" :
199
- secret_instance = client .CoreV1Api (api_config_handler ())
200
- secret_instance .create_namespaced_secret (
201
- namespace = namespace ,
202
- body = resource ,
203
- )
179
+ self ._component_level_up (namespace , api_instance )
204
180
except Exception as e : # pragma: no cover
205
181
return _kube_api_error_handling (e )
206
182
@@ -222,33 +198,7 @@ def down(self):
222
198
name = self .app_wrapper_name ,
223
199
)
224
200
else :
225
- with open (self .app_wrapper_yaml ) as f :
226
- yamls = yaml .load_all (f , Loader = yaml .FullLoader )
227
- for resource in yamls :
228
- if resource ["kind" ] == "RayCluster" :
229
- api_instance .delete_namespaced_custom_object (
230
- group = "ray.io" ,
231
- version = "v1alpha1" ,
232
- namespace = namespace ,
233
- plural = "rayclusters" ,
234
- name = self .app_wrapper_name ,
235
- )
236
- elif resource ["kind" ] == "Route" :
237
- name = resource ["metadata" ]["name" ]
238
- api_instance .delete_namespaced_custom_object (
239
- group = "route.openshift.io" ,
240
- version = "v1" ,
241
- namespace = namespace ,
242
- plural = "routes" ,
243
- name = name ,
244
- )
245
- elif resource ["kind" ] == "Secret" :
246
- name = resource ["metadata" ]["name" ]
247
- secret_instance = client .CoreV1Api (api_config_handler ())
248
- secret_instance .delete_namespaced_secret (
249
- namespace = namespace ,
250
- name = name ,
251
- )
201
+ self ._component_level_down (namespace , api_instance )
252
202
except Exception as e : # pragma: no cover
253
203
return _kube_api_error_handling (e )
254
204
@@ -297,7 +247,10 @@ def status(
297
247
298
248
# check the ray cluster status
299
249
cluster = _ray_cluster_status (self .config .name , self .config .namespace )
300
- if cluster and not cluster .status == RayClusterStatus .UNKNOWN :
250
+ if cluster :
251
+ if cluster .status == RayClusterStatus .UNKNOWN :
252
+ ready = False
253
+ status = CodeFlareClusterStatus .STARTING
301
254
if cluster .status == RayClusterStatus .READY :
302
255
ready = True
303
256
status = CodeFlareClusterStatus .READY
@@ -339,7 +292,7 @@ def wait_ready(self, timeout: Optional[int] = None, dashboard_check: bool = True
339
292
time = 0
340
293
while not ready :
341
294
status , ready = self .status (print_to_console = False )
342
- if self . config . mcad and status == CodeFlareClusterStatus .UNKNOWN :
295
+ if status == CodeFlareClusterStatus .UNKNOWN :
343
296
print (
344
297
"WARNING: Current cluster status is unknown, have you run cluster.up yet?"
345
298
)
@@ -486,6 +439,66 @@ def local_client_url(self):
486
439
else :
487
440
return "None"
488
441
442
+ def _component_level_up (
443
+ self , namespace : str , api_instance : client .CustomObjectsApi
444
+ ):
445
+ with open (self .app_wrapper_yaml ) as f :
446
+ yamls = yaml .load_all (f , Loader = yaml .FullLoader )
447
+ for resource in yamls :
448
+ if resource ["kind" ] == "RayCluster" :
449
+ api_instance .create_namespaced_custom_object (
450
+ group = "ray.io" ,
451
+ version = "v1alpha1" ,
452
+ namespace = namespace ,
453
+ plural = "rayclusters" ,
454
+ body = resource ,
455
+ )
456
+ elif resource ["kind" ] == "Route" :
457
+ api_instance .create_namespaced_custom_object (
458
+ group = "route.openshift.io" ,
459
+ version = "v1" ,
460
+ namespace = namespace ,
461
+ plural = "routes" ,
462
+ body = resource ,
463
+ )
464
+ elif resource ["kind" ] == "Secret" :
465
+ secret_instance = client .CoreV1Api (api_config_handler ())
466
+ secret_instance .create_namespaced_secret (
467
+ namespace = namespace ,
468
+ body = resource ,
469
+ )
470
+
471
+ def _component_level_down (
472
+ self , namespace : str , api_instance : client .CustomObjectsApi
473
+ ):
474
+ with open (self .app_wrapper_yaml ) as f :
475
+ yamls = yaml .load_all (f , Loader = yaml .FullLoader )
476
+ for resource in yamls :
477
+ if resource ["kind" ] == "RayCluster" :
478
+ api_instance .delete_namespaced_custom_object (
479
+ group = "ray.io" ,
480
+ version = "v1alpha1" ,
481
+ namespace = namespace ,
482
+ plural = "rayclusters" ,
483
+ name = self .app_wrapper_name ,
484
+ )
485
+ elif resource ["kind" ] == "Route" :
486
+ name = resource ["metadata" ]["name" ]
487
+ api_instance .delete_namespaced_custom_object (
488
+ group = "route.openshift.io" ,
489
+ version = "v1" ,
490
+ namespace = namespace ,
491
+ plural = "routes" ,
492
+ name = name ,
493
+ )
494
+ elif resource ["kind" ] == "Secret" :
495
+ name = resource ["metadata" ]["name" ]
496
+ secret_instance = client .CoreV1Api (api_config_handler ())
497
+ secret_instance .delete_namespaced_secret (
498
+ namespace = namespace ,
499
+ name = name ,
500
+ )
501
+
489
502
490
503
def list_all_clusters (namespace : str , print_to_console : bool = True ):
491
504
"""
0 commit comments