Skip to content

Commit 611dbca

Browse files
Adjust test cases and unit tests
1 parent 7a1c7cc commit 611dbca

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed

Diff for: src/codeflare_sdk/templates/base-template.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ spec:
121121
valueFrom:
122122
fieldRef:
123123
fieldPath: status.podIP
124+
- name: COOKIE_SECRET
125+
valueFrom:
126+
secretKeyRef:
127+
key: cookie_secret
128+
name: jobtest-oauth-config
124129
- name: RAY_USE_TLS
125130
value: "0"
126131
- name: RAY_TLS_SERVER_CERT
@@ -171,12 +176,6 @@ spec:
171176
- mountPath: /etc/ssl/certs/odh-ca-bundle.crt
172177
name: odh-ca-cert
173178
subPath: odh-ca-bundle.crt
174-
env:
175-
- name: COOKIE_SECRET
176-
valueFrom:
177-
secretKeyRef:
178-
name: jobtest-oauth-config
179-
key: cookie_secret
180179
initContainers:
181180
- command:
182181
- sh

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,15 @@ def update_names(yaml, item, appwrapper_name, cluster_name, namespace, openshift
226226
lower_meta = item.get("generictemplate", {}).get("metadata")
227227
lower_meta["labels"]["workload.codeflare.dev/appwrapper"] = appwrapper_name
228228
lower_meta["annotations"]["codeflare.dev/oauth"] = f"{openshift_oauth}"
229-
lower_spec = item.get("generictemplate", {}).get("spec")
230-
lower_spec["headGroupSpec"]["template"]["spec"]["containers"][0]["env"][-1][
231-
"valueFrom"
232-
]["secretKeyRef"]["name"] = f"{cluster_name}-oauth-config"
233229
lower_meta["name"] = cluster_name
234230
lower_meta["namespace"] = namespace
231+
lower_spec = item.get("generictemplate", {}).get("spec")
232+
if openshift_oauth:
233+
lower_spec["headGroupSpec"]["template"]["spec"]["containers"][0]["env"][1][
234+
"valueFrom"
235+
]["secretKeyRef"]["name"] = f"{cluster_name}-oauth-config"
236+
if not openshift_oauth:
237+
del lower_spec["headGroupSpec"]["template"]["spec"]["containers"][0]["env"][1]
235238

236239

237240
def update_labels(yaml, instascale, instance_types):
@@ -440,7 +443,7 @@ def enable_local_interactive(resources, cluster_name, namespace, ingress_domain)
440443
# update_tls_env
441444
item["generictemplate"]["spec"]["headGroupSpec"]["template"]["spec"]["containers"][
442445
0
443-
]["env"][1]["value"] = "1"
446+
]["env"][2]["value"] = "1"
444447
item["generictemplate"]["spec"]["workerGroupSpecs"][0]["template"]["spec"][
445448
"containers"
446449
][0]["env"][1]["value"] = "1"
@@ -612,7 +615,7 @@ def _create_oauth_sidecar_object(
612615
"--upstream=http://localhost:8265",
613616
f"--tls-cert={tls_mount_location}/tls.crt",
614617
f"--tls-key={tls_mount_location}/tls.key",
615-
f"--cookie-secret={b64encode(urandom(64)).decode('utf-8')}", # create random string for encrypting cookie
618+
"--cookie-secret=$(COOKIE_SECRET)",
616619
f'--openshift-delegate-urls={{"/":{{"resource":"pods","namespace":"{namespace}","verb":"get"}}}}',
617620
],
618621
image="registry.redhat.io/openshift4/ose-oauth-proxy@sha256:1ea6a01bf3e63cdcf125c6064cbd4a4a270deaf0f157b3eabb78f60556840366",

Diff for: tests/test-case-no-mcad.yamls

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
apiVersion: ray.io/v1
33
kind: RayCluster
44
metadata:
5+
annotations:
6+
codeflare.dev/oauth: 'False'
57
labels:
68
controller-tools.k8s.io: '1.0'
79
workload.codeflare.dev/appwrapper: unit-test-cluster-ray

Diff for: tests/test-case-prio.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ spec:
3232
apiVersion: ray.io/v1
3333
kind: RayCluster
3434
metadata:
35+
annotations:
36+
codeflare.dev/oauth: 'False'
3537
labels:
3638
controller-tools.k8s.io: '1.0'
3739
workload.codeflare.dev/appwrapper: prio-test-cluster

Diff for: tests/test-case.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ spec:
3131
apiVersion: ray.io/v1
3232
kind: RayCluster
3333
metadata:
34+
annotations:
35+
codeflare.dev/oauth: 'False'
3436
labels:
3537
controller-tools.k8s.io: '1.0'
3638
workload.codeflare.dev/appwrapper: unit-test-cluster

Diff for: tests/test-default-appwrapper.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ spec:
2929
apiVersion: ray.io/v1
3030
kind: RayCluster
3131
metadata:
32+
annotations:
33+
codeflare.dev/oauth: 'False'
3234
labels:
3335
controller-tools.k8s.io: '1.0'
3436
workload.codeflare.dev/appwrapper: unit-test-default-cluster

Diff for: tests/unit_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2793,11 +2793,11 @@ def test_enable_local_interactive(mocker):
27932793
# 3. Required Envs to enable TLS encryption between head and workers
27942794
for i in range(len(tls_env)):
27952795
assert (
2796-
head_group_spec["template"]["spec"]["containers"][0]["env"][i + 1]["name"]
2796+
head_group_spec["template"]["spec"]["containers"][0]["env"][i + 2]["name"]
27972797
== tls_env[i]["name"]
27982798
)
27992799
assert (
2800-
head_group_spec["template"]["spec"]["containers"][0]["env"][i + 1]["value"]
2800+
head_group_spec["template"]["spec"]["containers"][0]["env"][i + 2]["value"]
28012801
== tls_env[i]["value"]
28022802
)
28032803
assert (

0 commit comments

Comments
 (0)