Skip to content

Commit 369387c

Browse files
committed
Removed ability to customise ray client
1 parent 60a57c0 commit 369387c

File tree

1 file changed

+34
-80
lines changed

1 file changed

+34
-80
lines changed

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

+34-80
Original file line numberDiff line numberDiff line change
@@ -149,94 +149,50 @@ def update_dashboard_ingress(
149149

150150

151151
def update_rayclient_ingress(
152-
ingress_item, cluster_name, namespace, ingress_options, ingress_domain
152+
ingress_item, cluster_name, namespace, ingress_domain
153153
): # pragma: no cover
154154
metadata = ingress_item.get("generictemplate", {}).get("metadata")
155155
spec = ingress_item.get("generictemplate", {}).get("spec")
156-
if ingress_options != {}:
157-
for index, ingress_option in enumerate(ingress_options["ingresses"]):
158-
if "ingressName" not in ingress_option.keys():
159-
raise ValueError(
160-
f"Error: 'ingressName' is missing or empty for ingress item at index {index}"
161-
)
162-
if "port" not in ingress_option.keys():
163-
raise ValueError(
164-
f"Error: 'port' is missing or empty for ingress item at index {index}"
165-
)
166-
elif not isinstance(ingress_option["port"], int):
167-
raise ValueError(
168-
f"Error: 'port' is not of type int for ingress item at index {index}"
169-
)
170-
if ingress_option["port"] == 10001:
171-
metadata["name"] = ingress_option["ingressName"]
172-
metadata["namespace"] = namespace
173-
if "annotations" not in ingress_option.keys():
174-
del metadata["annotations"]
175-
else:
176-
metadata["annotations"] = ingress_option["annotations"]
177-
if "path" not in ingress_option.keys():
178-
del spec["rules"][0]["http"]["paths"][0]["path"]
179-
else:
180-
spec["rules"][0]["http"]["paths"][0]["path"] = ingress_option[
181-
"path"
182-
]
183-
if "pathType" not in ingress_option.keys():
184-
spec["rules"][0]["http"]["paths"][0][
185-
"pathType"
186-
] = "ImplementationSpecific"
187-
if "host" not in ingress_option.keys():
188-
del spec["rules"][0]["host"]
189-
else:
190-
spec["rules"][0]["host"] = ingress_option["host"]
191-
if "ingressClassName" not in ingress_option.keys():
192-
del spec["ingressClassName"]
193-
else:
194-
spec["ingressClassName"] = ingress_option["ingressClassName"]
195-
196-
spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
197-
"name"
198-
] = f"{cluster_name}-head-svc"
199-
else:
200-
metadata["name"] = f"rayclient-{cluster_name}"
201-
metadata["namespace"] = namespace
202-
metadata["labels"]["odh-ray-cluster-service"] = f"{cluster_name}-head-svc"
156+
metadata["name"] = f"rayclient-{cluster_name}"
157+
metadata["namespace"] = namespace
158+
metadata["labels"]["odh-ray-cluster-service"] = f"{cluster_name}-head-svc"
203159

204-
spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
205-
"name"
206-
] = f"{cluster_name}-head-svc"
160+
spec["rules"][0]["http"]["paths"][0]["backend"]["service"][
161+
"name"
162+
] = f"{cluster_name}-head-svc"
207163

208-
if is_openshift_cluster():
209-
try:
210-
config_check()
211-
api_client = client.CustomObjectsApi(api_config_handler())
212-
ingress = api_client.get_cluster_custom_object(
213-
"config.openshift.io", "v1", "ingresses", "cluster"
214-
)
215-
ingressClassName = "openshift-default"
216-
annotations = {
217-
"nginx.ingress.kubernetes.io/rewrite-target": "/",
218-
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
219-
"route.openshift.io/termination": "passthrough",
220-
}
221-
except Exception as e: # pragma: no cover
222-
return _kube_api_error_handling(e)
223-
domain = ingress["spec"]["domain"]
224-
elif ingress_domain is None:
225-
raise ValueError(
226-
"ingress_domain is invalid. For Kubernetes Clusters please specify an ingress domain"
164+
if is_openshift_cluster():
165+
try:
166+
config_check()
167+
api_client = client.CustomObjectsApi(api_config_handler())
168+
ingress = api_client.get_cluster_custom_object(
169+
"config.openshift.io", "v1", "ingresses", "cluster"
227170
)
228-
else:
229-
domain = ingress_domain
230-
ingressClassName = "nginx"
171+
ingressClassName = "openshift-default"
231172
annotations = {
232173
"nginx.ingress.kubernetes.io/rewrite-target": "/",
233174
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
234-
"nginx.ingress.kubernetes.io/ssl-passthrough": "true",
175+
"route.openshift.io/termination": "passthrough",
235176
}
177+
except Exception as e: # pragma: no cover
178+
return _kube_api_error_handling(e)
179+
domain = ingress["spec"]["domain"]
180+
elif ingress_domain is None:
181+
raise ValueError(
182+
"ingress_domain is invalid. For Kubernetes Clusters please specify an ingress domain"
183+
)
184+
else:
185+
domain = ingress_domain
186+
ingressClassName = "nginx"
187+
annotations = {
188+
"nginx.ingress.kubernetes.io/rewrite-target": "/",
189+
"nginx.ingress.kubernetes.io/ssl-redirect": "true",
190+
"nginx.ingress.kubernetes.io/ssl-passthrough": "true",
191+
}
236192

237-
metadata["annotations"] = annotations
238-
spec["ingressClassName"] = ingressClassName
239-
spec["rules"][0]["host"] = f"rayclient-{cluster_name}-{namespace}.{domain}"
193+
metadata["annotations"] = annotations
194+
spec["ingressClassName"] = ingressClassName
195+
spec["rules"][0]["host"] = f"rayclient-{cluster_name}-{namespace}.{domain}"
240196

241197

242198
def update_names(yaml, item, appwrapper_name, cluster_name, namespace):
@@ -504,9 +460,7 @@ def enable_local_interactive(
504460
domain = ingress_domain
505461

506462
command = command.replace("server-name", domain)
507-
update_rayclient_ingress(
508-
rayclient_ingress_item, cluster_name, namespace, ingress_options, domain
509-
)
463+
update_rayclient_ingress(rayclient_ingress_item, cluster_name, namespace, domain)
510464

511465
item["generictemplate"]["spec"]["headGroupSpec"]["template"]["spec"][
512466
"initContainers"

0 commit comments

Comments
 (0)