33
33
)
34
34
from ..utils .kube_api_helpers import _kube_api_error_handling
35
35
from ..utils .generate_yaml import is_openshift_cluster
36
- from ..utils .openshift_oauth import (
37
- create_openshift_oauth_objects ,
38
- delete_openshift_oauth_objects ,
39
- )
36
+
40
37
from .config import ClusterConfiguration
41
38
from .model import (
42
39
AppWrapper ,
@@ -86,14 +83,16 @@ def _client_headers(self):
86
83
87
84
@property
88
85
def _client_verify_tls (self ):
89
- return not self .config .openshift_oauth
86
+ if not is_openshift_cluster or not self .config .verify_tls :
87
+ return False
88
+ return True
90
89
91
90
@property
92
91
def job_client (self ):
93
92
k8client = api_config_handler () or client .ApiClient ()
94
93
if self ._job_submission_client :
95
94
return self ._job_submission_client
96
- if self . config . openshift_oauth :
95
+ if is_openshift_cluster () :
97
96
print (k8client .configuration .get_api_key_with_prefix ("authorization" ))
98
97
self ._job_submission_client = JobSubmissionClient (
99
98
self .cluster_dashboard_uri (),
@@ -191,6 +190,7 @@ def create_app_wrapper(self):
191
190
ingress_domain = self .config .ingress_domain
192
191
ingress_options = self .config .ingress_options
193
192
write_to_file = self .config .write_to_file
193
+ verify_tls = self .config .verify_tls
194
194
return generate_appwrapper (
195
195
name = name ,
196
196
namespace = namespace ,
@@ -213,10 +213,10 @@ def create_app_wrapper(self):
213
213
image_pull_secrets = image_pull_secrets ,
214
214
dispatch_priority = dispatch_priority ,
215
215
priority_val = priority_val ,
216
- openshift_oauth = self .config .openshift_oauth ,
217
216
ingress_domain = ingress_domain ,
218
217
ingress_options = ingress_options ,
219
218
write_to_file = write_to_file ,
219
+ verify_tls = verify_tls ,
220
220
)
221
221
222
222
# creates a new cluster with the provided or default spec
@@ -226,10 +226,6 @@ def up(self):
226
226
the MCAD queue.
227
227
"""
228
228
namespace = self .config .namespace
229
- if self .config .openshift_oauth :
230
- create_openshift_oauth_objects (
231
- cluster_name = self .config .name , namespace = namespace
232
- )
233
229
234
230
try :
235
231
config_check ()
@@ -281,11 +277,6 @@ def down(self):
281
277
except Exception as e : # pragma: no cover
282
278
return _kube_api_error_handling (e )
283
279
284
- if self .config .openshift_oauth :
285
- delete_openshift_oauth_objects (
286
- cluster_name = self .config .name , namespace = namespace
287
- )
288
-
289
280
def status (
290
281
self , print_to_console : bool = True
291
282
) -> Tuple [CodeFlareClusterStatus , bool ]:
@@ -500,26 +491,21 @@ def torchx_config(
500
491
return to_return
501
492
502
493
def from_k8_cluster_object (
503
- rc , mcad = True , ingress_domain = None , ingress_options = {}, write_to_file = False
494
+ rc ,
495
+ mcad = True ,
496
+ ingress_domain = None ,
497
+ ingress_options = {},
498
+ write_to_file = False ,
499
+ verify_tls = True ,
504
500
):
505
501
config_check ()
506
- openshift_oauth = False
507
502
if (
508
503
rc ["metadata" ]["annotations" ]["sdk.codeflare.dev/local_interactive" ]
509
504
== "True"
510
505
):
511
506
local_interactive = True
512
507
else :
513
508
local_interactive = False
514
- if "codeflare.dev/oauth" in rc ["metadata" ]["annotations" ]:
515
- openshift_oauth = (
516
- rc ["metadata" ]["annotations" ]["codeflare.dev/oauth" ] == "True"
517
- )
518
- else :
519
- for container in rc ["spec" ]["headGroupSpec" ]["template" ]["spec" ][
520
- "containers"
521
- ]:
522
- openshift_oauth = "oauth-proxy" in container ["name" ]
523
509
machine_types = (
524
510
rc ["metadata" ]["labels" ]["orderedinstance" ].split ("_" )
525
511
if "orderedinstance" in rc ["metadata" ]["labels" ]
@@ -570,7 +556,7 @@ def from_k8_cluster_object(
570
556
ingress_domain = ingress_domain ,
571
557
ingress_options = ingress_options ,
572
558
write_to_file = write_to_file ,
573
- openshift_oauth = openshift_oauth ,
559
+ verify_tls = verify_tls ,
574
560
)
575
561
return Cluster (cluster_config )
576
562
@@ -655,7 +641,10 @@ def get_current_namespace(): # pragma: no cover
655
641
656
642
657
643
def get_cluster (
658
- cluster_name : str , namespace : str = "default" , write_to_file : bool = False
644
+ cluster_name : str ,
645
+ namespace : str = "default" ,
646
+ write_to_file : bool = False ,
647
+ verify_tls : bool = True ,
659
648
):
660
649
try :
661
650
config_check ()
@@ -729,6 +718,7 @@ def get_cluster(
729
718
ingress_domain = ingress_domain ,
730
719
ingress_options = ingress_options ,
731
720
write_to_file = write_to_file ,
721
+ verify_tls = verify_tls ,
732
722
)
733
723
raise FileNotFoundError (
734
724
f"Cluster { cluster_name } is not found in { namespace } namespace"
0 commit comments