Skip to content

Commit ad0e30c

Browse files
Add verify_tls to ClusterConfiguration
1 parent f85929c commit ad0e30c

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

Diff for: src/codeflare_sdk/cluster/cluster.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ def _client_headers(self):
8181
)
8282
}
8383

84+
@property
85+
def _client_verify_tls(self):
86+
if not is_openshift_cluster or not self.config.verify_tls:
87+
return False
88+
return True
89+
8490
@property
8591
def job_client(self):
8692
k8client = api_config_handler() or client.ApiClient()
@@ -91,7 +97,7 @@ def job_client(self):
9197
self._job_submission_client = JobSubmissionClient(
9298
self.cluster_dashboard_uri(),
9399
headers=self._client_headers,
94-
verify=False,
100+
verify=self._client_verify_tls,
95101
)
96102
else:
97103
self._job_submission_client = JobSubmissionClient(
@@ -184,6 +190,7 @@ def create_app_wrapper(self):
184190
ingress_domain = self.config.ingress_domain
185191
ingress_options = self.config.ingress_options
186192
write_to_file = self.config.write_to_file
193+
verify_tls = self.config.verify_tls
187194
return generate_appwrapper(
188195
name=name,
189196
namespace=namespace,
@@ -209,6 +216,7 @@ def create_app_wrapper(self):
209216
ingress_domain=ingress_domain,
210217
ingress_options=ingress_options,
211218
write_to_file=write_to_file,
219+
verify_tls=verify_tls,
212220
)
213221

214222
# creates a new cluster with the provided or default spec
@@ -346,7 +354,7 @@ def is_dashboard_ready(self) -> bool:
346354
self.cluster_dashboard_uri(),
347355
headers=self._client_headers,
348356
timeout=5,
349-
verify=False,
357+
verify=self._client_verify_tls,
350358
)
351359
except requests.exceptions.SSLError: # pragma no cover
352360
# SSL exception occurs when oauth ingress has been created but cluster is not up
@@ -483,7 +491,12 @@ def torchx_config(
483491
return to_return
484492

485493
def from_k8_cluster_object(
486-
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,
487500
):
488501
config_check()
489502
if (
@@ -543,6 +556,7 @@ def from_k8_cluster_object(
543556
ingress_domain=ingress_domain,
544557
ingress_options=ingress_options,
545558
write_to_file=write_to_file,
559+
verify_tls=verify_tls,
546560
)
547561
return Cluster(cluster_config)
548562

@@ -627,7 +641,10 @@ def get_current_namespace(): # pragma: no cover
627641

628642

629643
def get_cluster(
630-
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,
631648
):
632649
try:
633650
config_check()
@@ -701,6 +718,7 @@ def get_cluster(
701718
ingress_domain=ingress_domain,
702719
ingress_options=ingress_options,
703720
write_to_file=write_to_file,
721+
verify_tls=verify_tls,
704722
)
705723
raise FileNotFoundError(
706724
f"Cluster {cluster_name} is not found in {namespace} namespace"

Diff for: src/codeflare_sdk/cluster/config.py

+7
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ class ClusterConfiguration:
5555
ingress_options: dict = field(default_factory=dict)
5656
ingress_domain: str = None
5757
write_to_file: bool = False
58+
verify_tls: bool = True
59+
60+
def __post_init__(self):
61+
if not self.verify_tls:
62+
print(
63+
"Warning: TLS verification has been disabled - Endpoint checks will be bypassed"
64+
)

Diff for: src/codeflare_sdk/utils/generate_yaml.py

+1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ def generate_appwrapper(
710710
ingress_domain: str,
711711
ingress_options: dict,
712712
write_to_file: bool,
713+
verify_tls: bool,
713714
):
714715
user_yaml = read_template(template)
715716
appwrapper_name, cluster_name = gen_names(name)

Diff for: tests/unit_test_support.py

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def createClusterWithConfig(mocker):
6060
return_value={"spec": {"domain": "apps.cluster.awsroute.org"}},
6161
)
6262
cluster = Cluster(createClusterConfig())
63-
cluster.config.image = "quay.io/project-codeflare/ray:latest-py39-cu118"
6463
return cluster
6564

6665

0 commit comments

Comments
 (0)