3333)
3434from ..utils .kube_api_helpers import _kube_api_error_handling
3535from ..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+
4037from .config import ClusterConfiguration
4138from .model import (
4239 AppWrapper ,
@@ -86,14 +83,16 @@ def _client_headers(self):
8683
8784 @property
8885 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
9089
9190 @property
9291 def job_client (self ):
9392 k8client = api_config_handler () or client .ApiClient ()
9493 if self ._job_submission_client :
9594 return self ._job_submission_client
96- if self . config . openshift_oauth :
95+ if is_openshift_cluster () :
9796 print (k8client .configuration .get_api_key_with_prefix ("authorization" ))
9897 self ._job_submission_client = JobSubmissionClient (
9998 self .cluster_dashboard_uri (),
@@ -191,6 +190,7 @@ def create_app_wrapper(self):
191190 ingress_domain = self .config .ingress_domain
192191 ingress_options = self .config .ingress_options
193192 write_to_file = self .config .write_to_file
193+ verify_tls = self .config .verify_tls
194194 return generate_appwrapper (
195195 name = name ,
196196 namespace = namespace ,
@@ -213,10 +213,10 @@ def create_app_wrapper(self):
213213 image_pull_secrets = image_pull_secrets ,
214214 dispatch_priority = dispatch_priority ,
215215 priority_val = priority_val ,
216- openshift_oauth = self .config .openshift_oauth ,
217216 ingress_domain = ingress_domain ,
218217 ingress_options = ingress_options ,
219218 write_to_file = write_to_file ,
219+ verify_tls = verify_tls ,
220220 )
221221
222222 # creates a new cluster with the provided or default spec
@@ -226,10 +226,6 @@ def up(self):
226226 the MCAD queue.
227227 """
228228 namespace = self .config .namespace
229- if self .config .openshift_oauth :
230- create_openshift_oauth_objects (
231- cluster_name = self .config .name , namespace = namespace
232- )
233229
234230 try :
235231 config_check ()
@@ -281,11 +277,6 @@ def down(self):
281277 except Exception as e : # pragma: no cover
282278 return _kube_api_error_handling (e )
283279
284- if self .config .openshift_oauth :
285- delete_openshift_oauth_objects (
286- cluster_name = self .config .name , namespace = namespace
287- )
288-
289280 def status (
290281 self , print_to_console : bool = True
291282 ) -> Tuple [CodeFlareClusterStatus , bool ]:
@@ -500,26 +491,21 @@ def torchx_config(
500491 return to_return
501492
502493 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 ,
504500 ):
505501 config_check ()
506- openshift_oauth = False
507502 if (
508503 rc ["metadata" ]["annotations" ]["sdk.codeflare.dev/local_interactive" ]
509504 == "True"
510505 ):
511506 local_interactive = True
512507 else :
513508 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" ]
523509 machine_types = (
524510 rc ["metadata" ]["labels" ]["orderedinstance" ].split ("_" )
525511 if "orderedinstance" in rc ["metadata" ]["labels" ]
@@ -570,7 +556,7 @@ def from_k8_cluster_object(
570556 ingress_domain = ingress_domain ,
571557 ingress_options = ingress_options ,
572558 write_to_file = write_to_file ,
573- openshift_oauth = openshift_oauth ,
559+ verify_tls = verify_tls ,
574560 )
575561 return Cluster (cluster_config )
576562
@@ -655,7 +641,10 @@ def get_current_namespace(): # pragma: no cover
655641
656642
657643def 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 ,
659648):
660649 try :
661650 config_check ()
@@ -729,6 +718,7 @@ def get_cluster(
729718 ingress_domain = ingress_domain ,
730719 ingress_options = ingress_options ,
731720 write_to_file = write_to_file ,
721+ verify_tls = verify_tls ,
732722 )
733723 raise FileNotFoundError (
734724 f"Cluster { cluster_name } is not found in { namespace } namespace"
0 commit comments