Skip to content

Commit 0cddf34

Browse files
Remove ingress_options and update tests
1 parent 2773cd8 commit 0cddf34

9 files changed

+98
-190
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ def from_k8_cluster_object(
494494
rc,
495495
mcad=True,
496496
ingress_domain=None,
497-
ingress_options={},
498497
write_to_file=False,
499498
verify_tls=True,
500499
):
@@ -554,7 +553,7 @@ def from_k8_cluster_object(
554553
local_interactive=local_interactive,
555554
mcad=mcad,
556555
ingress_domain=ingress_domain,
557-
ingress_options=ingress_options,
556+
# ingress_options=ingress_options,
558557
write_to_file=write_to_file,
559558
verify_tls=verify_tls,
560559
)
@@ -662,7 +661,7 @@ def get_cluster(
662661
if rc["metadata"]["name"] == cluster_name:
663662
mcad = _check_aw_exists(cluster_name, namespace)
664663
ingress_host = None
665-
ingress_options = {}
664+
# ingress_options = {}
666665
if not is_openshift_cluster():
667666
try:
668667
config_check()
@@ -675,48 +674,48 @@ def get_cluster(
675674
and ingress.metadata.labels["ingress-owner"] == cluster_name
676675
):
677676
ingress_host = ingress.spec.rules[0].host
678-
if (
679-
"ingress-options" in ingress.metadata.labels
680-
and ingress.metadata.labels["ingress-options"] == "true"
681-
):
682-
ingress_name = ingress.metadata.name
683-
port = (
684-
ingress.spec.rules[0]
685-
.http.paths[0]
686-
.backend.service.port.number
687-
)
688-
annotations = ingress.metadata.annotations
689-
path = ingress.spec.rules[0].http.paths[0].path
690-
ingress_class_name = ingress.spec.ingress_class_name
691-
path_type = (
692-
ingress.spec.rules[0].http.paths[0].path_type
693-
)
694-
695-
ingress_options = {
696-
"ingresses": [
697-
{
698-
"ingressName": ingress_name,
699-
"port": port,
700-
"annotations": annotations,
701-
"ingressClassName": ingress_class_name,
702-
"pathType": path_type,
703-
"path": path,
704-
"host": ingress_host,
705-
}
706-
]
707-
}
677+
# if (
678+
# "ingress-options" in ingress.metadata.labels
679+
# and ingress.metadata.labels["ingress-options"] == "true"
680+
# ):
681+
# ingress_name = ingress.metadata.name
682+
# port = (
683+
# ingress.spec.rules[0]
684+
# .http.paths[0]
685+
# .backend.service.port.number
686+
# )
687+
# annotations = ingress.metadata.annotations
688+
# path = ingress.spec.rules[0].http.paths[0].path
689+
# ingress_class_name = ingress.spec.ingress_class_name
690+
# path_type = (
691+
# ingress.spec.rules[0].http.paths[0].path_type
692+
# )
693+
694+
# ingress_options = {
695+
# "ingresses": [
696+
# {
697+
# "ingressName": ingress_name,
698+
# "port": port,
699+
# "annotations": annotations,
700+
# "ingressClassName": ingress_class_name,
701+
# "pathType": path_type,
702+
# "path": path,
703+
# "host": ingress_host,
704+
# }
705+
# ]
706+
# }
708707
except Exception as e: # pragma: no cover
709708
return _kube_api_error_handling(e)
710709
# We gather the ingress domain from the host
711-
if ingress_host is not None and ingress_options == {}:
710+
if ingress_host is not None:
712711
ingress_domain = ingress_host.split(".", 1)[1]
713712
else:
714713
ingress_domain = None
715714
return Cluster.from_k8_cluster_object(
716715
rc,
717716
mcad=mcad,
718717
ingress_domain=ingress_domain,
719-
ingress_options=ingress_options,
718+
# ingress_options=ingress_options,
720719
write_to_file=write_to_file,
721720
verify_tls=verify_tls,
722721
)

src/codeflare_sdk/cluster/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ClusterConfiguration:
5252
local_interactive: bool = False
5353
image_pull_secrets: list = field(default_factory=list)
5454
dispatch_priority: str = None
55-
ingress_options: dict = field(default_factory=dict)
55+
# ingress_options: dict = field(default_factory=dict)
5656
ingress_domain: str = None
5757
write_to_file: bool = False
5858
verify_tls: bool = True

tests/e2e/mnist_raycluster_sdk_test.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ def test_mnist_ray_cluster_sdk(self):
3636

3737
def run_mnist_raycluster_sdk(self):
3838
ray_image = get_ray_image()
39-
host = os.getenv("CLUSTER_HOSTNAME")
40-
41-
ingress_options = {}
42-
if host is not None:
43-
ingress_options = {
44-
"ingresses": [
45-
{
46-
"ingressName": "ray-dashboard",
47-
"port": 8265,
48-
"pathType": "Prefix",
49-
"path": "/",
50-
"host": host,
51-
"annotations": {
52-
"nginx.ingress.kubernetes.io/proxy-body-size": "100M",
53-
},
54-
},
55-
]
56-
}
39+
# host = os.getenv("CLUSTER_HOSTNAME")
40+
41+
# ingress_options = {}
42+
# if host is not None:
43+
# ingress_options = {
44+
# "ingresses": [
45+
# {
46+
# "ingressName": "ray-dashboard",
47+
# "port": 8265,
48+
# "pathType": "Prefix",
49+
# "path": "/",
50+
# "host": host,
51+
# "annotations": {
52+
# "nginx.ingress.kubernetes.io/proxy-body-size": "100M",
53+
# },
54+
# },
55+
# ]
56+
# }
5757

5858
cluster = Cluster(
5959
ClusterConfiguration(
@@ -69,7 +69,7 @@ def run_mnist_raycluster_sdk(self):
6969
num_gpus=0,
7070
instascale=False,
7171
image=ray_image,
72-
ingress_options=ingress_options,
72+
# ingress_options=ingress_options,
7373
write_to_file=True,
7474
)
7575
)

tests/e2e/start_ray_cluster.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77

88
namespace = sys.argv[1]
99
ray_image = os.getenv("RAY_IMAGE")
10-
host = os.getenv("CLUSTER_HOSTNAME")
11-
12-
ingress_options = {}
13-
if host is not None:
14-
ingress_options = {
15-
"ingresses": [
16-
{
17-
"ingressName": "ray-dashboard",
18-
"port": 8265,
19-
"pathType": "Prefix",
20-
"path": "/",
21-
"host": host,
22-
},
23-
]
24-
}
10+
# host = os.getenv("CLUSTER_HOSTNAME")
11+
12+
# ingress_options = {}
13+
# if host is not None:
14+
# ingress_options = {
15+
# "ingresses": [
16+
# {
17+
# "ingressName": "ray-dashboard",
18+
# "port": 8265,
19+
# "pathType": "Prefix",
20+
# "path": "/",
21+
# "host": host,
22+
# },
23+
# ]
24+
# }
2525

2626
cluster = Cluster(
2727
ClusterConfiguration(
@@ -37,7 +37,7 @@
3737
num_gpus=0,
3838
instascale=False,
3939
image=ray_image,
40-
ingress_options=ingress_options,
40+
# ingress_options=ingress_options,
4141
)
4242
)
4343

tests/test-case-no-mcad.yamls

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,25 +197,3 @@ spec:
197197
name: odh-trusted-ca-bundle
198198
optional: true
199199
name: odh-ca-cert
200-
---
201-
apiVersion: networking.k8s.io/v1
202-
kind: Ingress
203-
metadata:
204-
labels:
205-
ingress-options: 'false'
206-
ingress-owner: unit-test-cluster-ray
207-
name: ray-dashboard-unit-test-cluster-ray
208-
namespace: ns
209-
spec:
210-
ingressClassName: nginx
211-
rules:
212-
- host: ray-dashboard-unit-test-cluster-ray-ns.apps.cluster.awsroute.org
213-
http:
214-
paths:
215-
- backend:
216-
service:
217-
name: unit-test-cluster-ray-head-svc
218-
port:
219-
number: 8265
220-
path: /
221-
pathType: Prefix

tests/test-case-prio.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,4 @@ spec:
230230
optional: true
231231
name: odh-ca-cert
232232
replicas: 1
233-
- generictemplate:
234-
apiVersion: networking.k8s.io/v1
235-
kind: Ingress
236-
metadata:
237-
labels:
238-
ingress-options: 'false'
239-
ingress-owner: prio-test-cluster
240-
name: ray-dashboard-prio-test-cluster
241-
namespace: ns
242-
spec:
243-
ingressClassName: nginx
244-
rules:
245-
- host: ray-dashboard-prio-test-cluster-ns.apps.cluster.awsroute.org
246-
http:
247-
paths:
248-
- backend:
249-
service:
250-
name: prio-test-cluster-head-svc
251-
port:
252-
number: 8265
253-
path: /
254-
pathType: Prefix
255-
replicas: 1
256233
Items: []

tests/test-case.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -227,27 +227,4 @@ spec:
227227
optional: true
228228
name: odh-ca-cert
229229
replicas: 1
230-
- generictemplate:
231-
apiVersion: networking.k8s.io/v1
232-
kind: Ingress
233-
metadata:
234-
labels:
235-
ingress-options: 'false'
236-
ingress-owner: unit-test-cluster
237-
name: ray-dashboard-unit-test-cluster
238-
namespace: ns
239-
spec:
240-
ingressClassName: nginx
241-
rules:
242-
- host: ray-dashboard-unit-test-cluster-ns.apps.cluster.awsroute.org
243-
http:
244-
paths:
245-
- backend:
246-
service:
247-
name: unit-test-cluster-head-svc
248-
port:
249-
number: 8265
250-
path: /
251-
pathType: Prefix
252-
replicas: 1
253230
Items: []

tests/test-default-appwrapper.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,27 +205,4 @@ spec:
205205
optional: true
206206
name: odh-ca-cert
207207
replicas: 1
208-
- generictemplate:
209-
apiVersion: networking.k8s.io/v1
210-
kind: Ingress
211-
metadata:
212-
labels:
213-
ingress-options: 'false'
214-
ingress-owner: unit-test-default-cluster
215-
name: ray-dashboard-unit-test-default-cluster
216-
namespace: opendatahub
217-
spec:
218-
ingressClassName: nginx
219-
rules:
220-
- host: ray-dashboard-unit-test-default-cluster-opendatahub.apps.cluster.awsroute.org
221-
http:
222-
paths:
223-
- backend:
224-
service:
225-
name: unit-test-default-cluster-head-svc
226-
port:
227-
number: 8265
228-
path: /
229-
pathType: Prefix
230-
replicas: 1
231208
Items: []

tests/unit_test.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ def test_enable_local_interactive(mocker):
30583058
worker_group_spec = aw_spec["resources"]["GenericItems"][0]["generictemplate"][
30593059
"spec"
30603060
]["workerGroupSpecs"]
3061-
ca_secret = aw_spec["resources"]["GenericItems"][5]["generictemplate"]
3061+
ca_secret = aw_spec["resources"]["GenericItems"][1]["generictemplate"]
30623062
# At a minimal, make sure the following items are presented in the appwrapper spec.resources.
30633063
# 1. headgroup has the initContainers command to generated TLS cert from the mounted CA cert.
30643064
# Note: In this particular command, the DNS.5 in [alt_name] must match the exposed local_client_url: rayclient-{cluster_name}.{namespace}.{ingress_domain}
@@ -3113,33 +3113,33 @@ def test_enable_local_interactive(mocker):
31133113
assert ca_secret["metadata"]["name"] == f"ca-secret-{cluster_name}"
31143114
assert ca_secret["metadata"]["namespace"] == namespace
31153115

3116-
# 5. Rayclient ingress - Kind
3117-
rayclient_ingress = aw_spec["resources"]["GenericItems"][3]["generictemplate"]
3118-
paths = [
3119-
{
3120-
"backend": {
3121-
"service": {
3122-
"name": f"{cluster_name}-head-svc",
3123-
"port": {"number": 10001},
3124-
}
3125-
},
3126-
"path": "",
3127-
"pathType": "ImplementationSpecific",
3128-
}
3129-
]
3130-
3131-
assert rayclient_ingress["kind"] == "Ingress"
3132-
assert rayclient_ingress["metadata"]["namespace"] == namespace
3133-
assert rayclient_ingress["metadata"]["annotations"] == {
3134-
"nginx.ingress.kubernetes.io/rewrite-target": "/",
3135-
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
3136-
"nginx.ingress.kubernetes.io/ssl-passthrough": "true",
3137-
}
3138-
assert rayclient_ingress["metadata"]["name"] == f"rayclient-{cluster_name}"
3139-
assert rayclient_ingress["spec"]["rules"][0] == {
3140-
"host": f"rayclient-{cluster_name}-{namespace}.{ingress_domain}",
3141-
"http": {"paths": paths},
3142-
}
3116+
# # 5. Rayclient ingress - Kind
3117+
# rayclient_ingress = aw_spec["resources"]["GenericItems"][3]["generictemplate"]
3118+
# paths = [
3119+
# {
3120+
# "backend": {
3121+
# "service": {
3122+
# "name": f"{cluster_name}-head-svc",
3123+
# "port": {"number": 10001},
3124+
# }
3125+
# },
3126+
# "path": "",
3127+
# "pathType": "ImplementationSpecific",
3128+
# }
3129+
# ]
3130+
3131+
# assert rayclient_ingress["kind"] == "Ingress"
3132+
# assert rayclient_ingress["metadata"]["namespace"] == namespace
3133+
# assert rayclient_ingress["metadata"]["annotations"] == {
3134+
# "nginx.ingress.kubernetes.io/rewrite-target": "/",
3135+
# "nginx.ingress.kubernetes.io/ssl-redirect": "true",
3136+
# "nginx.ingress.kubernetes.io/ssl-passthrough": "true",
3137+
# }
3138+
# assert rayclient_ingress["metadata"]["name"] == f"rayclient-{cluster_name}"
3139+
# assert rayclient_ingress["spec"]["rules"][0] == {
3140+
# "host": f"rayclient-{cluster_name}-{namespace}.{ingress_domain}",
3141+
# "http": {"paths": paths},
3142+
# }
31433143

31443144

31453145
def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):

0 commit comments

Comments
 (0)