Skip to content

Commit 217522c

Browse files
committed
fix(RHOAIENG-20531): propagate annotations to ray pods
Signed-off-by: Pat O'Connor <[email protected]>
1 parent c311665 commit 217522c

File tree

10 files changed

+112
-11
lines changed

10 files changed

+112
-11
lines changed

demo-notebooks/guided-demos/0_basic_ray.ipynb

+1-6
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,7 @@
203203
"name": "python",
204204
"nbconvert_exporter": "python",
205205
"pygments_lexer": "ipython3",
206-
"version": "3.9.18"
207-
},
208-
"vscode": {
209-
"interpreter": {
210-
"hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac"
211-
}
206+
"version": "3.11.11"
212207
}
213208
},
214209
"nbformat": 4,

src/codeflare_sdk/common/utils/unit_test_support.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def create_cluster_config(num_workers=2, write_to_file=False):
4040
worker_memory_limits=6,
4141
appwrapper=True,
4242
write_to_file=write_to_file,
43+
annotations={
44+
"app.kubernetes.io/managed-by": "test-prefix",
45+
"key1": "value1",
46+
"key2": "value2",
47+
},
4348
)
4449
return config
4550

@@ -498,7 +503,11 @@ def create_cluster_all_config_params(mocker, cluster_name, is_appwrapper) -> Clu
498503
extended_resource_mapping={"example.com/gpu": "GPU", "intel.com/gpu": "TPU"},
499504
overwrite_default_resource_mapping=True,
500505
local_queue="local-queue-default",
501-
annotations={"key1": "value1", "key2": "value2"},
506+
annotations={
507+
"app.kubernetes.io/managed-by": "test-prefix",
508+
"key1": "value1",
509+
"key2": "value2",
510+
},
502511
volumes=volumes,
503512
volume_mounts=volume_mounts,
504513
)

src/codeflare_sdk/ray/cluster/build_ray_cluster.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ def build_ray_cluster(cluster: "codeflare_sdk.ray.cluster.Cluster"):
140140
"resources": head_resources,
141141
},
142142
"template": {
143+
"metadata": V1ObjectMeta(cluster.config.annotations),
143144
"spec": get_pod_spec(
144145
cluster,
145146
[get_head_container_spec(cluster)],
146147
cluster.config.head_tolerations,
147-
)
148+
),
148149
},
149150
},
150151
"workerGroupSpecs": [
@@ -159,11 +160,12 @@ def build_ray_cluster(cluster: "codeflare_sdk.ray.cluster.Cluster"):
159160
"resources": worker_resources,
160161
},
161162
"template": V1PodTemplateSpec(
163+
metadata=V1ObjectMeta(cluster.config.annotations),
162164
spec=get_pod_spec(
163165
cluster,
164166
[get_worker_container_spec(cluster)],
165167
cluster.config.worker_tolerations,
166-
)
168+
),
167169
),
168170
}
169171
],

src/codeflare_sdk/ray/cluster/test_config.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ def test_default_cluster_creation(mocker):
3535
mocker.patch("kubernetes.client.ApisApi.get_api_versions")
3636
mocker.patch("kubernetes.client.CustomObjectsApi.list_namespaced_custom_object")
3737

38-
cluster = Cluster(ClusterConfiguration(name="default-cluster", namespace="ns"))
38+
cluster = Cluster(
39+
ClusterConfiguration(
40+
name="default-cluster",
41+
namespace="ns",
42+
annotations={
43+
"app.kubernetes.io/managed-by": "test-prefix",
44+
"key1": "value1",
45+
"key2": "value2",
46+
},
47+
)
48+
)
3949

4050
expected_rc = apply_template(
4151
f"{expected_clusters_dir}/ray/default-ray-cluster.yaml",
@@ -50,7 +60,16 @@ def test_default_appwrapper_creation(mocker):
5060
mocker.patch("kubernetes.client.CustomObjectsApi.list_namespaced_custom_object")
5161

5262
cluster = Cluster(
53-
ClusterConfiguration(name="default-appwrapper", namespace="ns", appwrapper=True)
63+
ClusterConfiguration(
64+
name="default-appwrapper",
65+
namespace="ns",
66+
appwrapper=True,
67+
annotations={
68+
"app.kubernetes.io/managed-by": "test-prefix",
69+
"key1": "value1",
70+
"key2": "value2",
71+
},
72+
)
5473
)
5574

5675
expected_aw = apply_template(

tests/test_cluster_yamls/appwrapper/unit-test-all-params.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ spec:
4242
resources: '"{\"TPU\": 2}"'
4343
serviceType: ClusterIP
4444
template:
45+
metadata:
46+
annotations:
47+
app.kubernetes.io/managed-by: test-prefix
48+
key1: value1
49+
key2: value2
4550
spec:
4651
containers:
4752
- env:
@@ -142,6 +147,11 @@ spec:
142147
resources: '"{}"'
143148
replicas: 10
144149
template:
150+
metadata:
151+
annotations:
152+
app.kubernetes.io/managed-by: test-prefix
153+
key1: value1
154+
key2: value2
145155
spec:
146156
containers:
147157
- env:

tests/test_cluster_yamls/kueue/aw_kueue.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
apiVersion: ray.io/v1
1212
kind: RayCluster
1313
metadata:
14+
annotations:
15+
app.kubernetes.io/managed-by: test-prefix
16+
key1: value1
17+
key2: value2
1418
labels:
1519
controller-tools.k8s.io: '1.0'
1620
name: unit-test-aw-kueue
@@ -36,6 +40,11 @@ spec:
3640
resources: '"{}"'
3741
serviceType: ClusterIP
3842
template:
43+
metadata:
44+
annotations:
45+
app.kubernetes.io/managed-by: test-prefix
46+
key1: value1
47+
key2: value2
3948
spec:
4049
containers:
4150
- image: "${image}"
@@ -101,6 +110,11 @@ spec:
101110
resources: '"{}"'
102111
replicas: 2
103112
template:
113+
metadata:
114+
annotations:
115+
app.kubernetes.io/managed-by: test-prefix
116+
key1: value1
117+
key2: value2
104118
spec:
105119
containers:
106120
- image: "${image}"

tests/test_cluster_yamls/kueue/ray_cluster_kueue.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ spec:
1111
apiVersion: ray.io/v1
1212
kind: RayCluster
1313
metadata:
14+
annotations:
15+
app.kubernetes.io/managed-by: test-prefix
16+
key1: value1
17+
key2: value2
1418
labels:
1519
controller-tools.k8s.io: '1.0'
1620
name: unit-test-cluster-kueue
@@ -36,6 +40,11 @@ spec:
3640
resources: '"{}"'
3741
serviceType: ClusterIP
3842
template:
43+
metadata:
44+
annotations:
45+
app.kubernetes.io/managed-by: test-prefix
46+
key1: value1
47+
key2: value2
3948
spec:
4049
containers:
4150
- image: "${image}"
@@ -101,6 +110,11 @@ spec:
101110
resources: '"{}"'
102111
replicas: 2
103112
template:
113+
metadata:
114+
annotations:
115+
app.kubernetes.io/managed-by: test-prefix
116+
key1: value1
117+
key2: value2
104118
spec:
105119
containers:
106120
- image: "${image}"

tests/test_cluster_yamls/ray/default-appwrapper.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ spec:
99
apiVersion: ray.io/v1
1010
kind: RayCluster
1111
metadata:
12+
annotations:
13+
app.kubernetes.io/managed-by: test-prefix
14+
key1: value1
15+
key2: value2
1216
labels:
1317
controller-tools.k8s.io: '1.0'
1418
name: default-appwrapper
@@ -34,6 +38,11 @@ spec:
3438
resources: '"{}"'
3539
serviceType: ClusterIP
3640
template:
41+
metadata:
42+
annotations:
43+
app.kubernetes.io/managed-by: test-prefix
44+
key1: value1
45+
key2: value2
3746
spec:
3847
containers:
3948
- image: "${image}"
@@ -99,6 +108,11 @@ spec:
99108
resources: '"{}"'
100109
replicas: 1
101110
template:
111+
metadata:
112+
annotations:
113+
app.kubernetes.io/managed-by: test-prefix
114+
key1: value1
115+
key2: value2
102116
spec:
103117
containers:
104118
- image: "${image}"

tests/test_cluster_yamls/ray/default-ray-cluster.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
apiVersion: ray.io/v1
22
kind: RayCluster
33
metadata:
4+
annotations:
5+
app.kubernetes.io/managed-by: test-prefix
6+
key1: value1
7+
key2: value2
48
labels:
59
controller-tools.k8s.io: '1.0'
610
name: default-cluster
@@ -26,6 +30,11 @@ spec:
2630
resources: '"{}"'
2731
serviceType: ClusterIP
2832
template:
33+
metadata:
34+
annotations:
35+
app.kubernetes.io/managed-by: test-prefix
36+
key1: value1
37+
key2: value2
2938
spec:
3039
containers:
3140
- image: "${image}"
@@ -91,6 +100,11 @@ spec:
91100
resources: '"{}"'
92101
replicas: 1
93102
template:
103+
metadata:
104+
annotations:
105+
app.kubernetes.io/managed-by: test-prefix
106+
key1: value1
107+
key2: value2
94108
spec:
95109
containers:
96110
- image: "${image}"

tests/test_cluster_yamls/ray/unit-test-all-params.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ spec:
3333
resources: '"{\"TPU\": 2}"'
3434
serviceType: ClusterIP
3535
template:
36+
metadata:
37+
annotations:
38+
app.kubernetes.io/managed-by: test-prefix
39+
key1: value1
40+
key2: value2
3641
spec:
3742
containers:
3843
- env:
@@ -133,6 +138,11 @@ spec:
133138
resources: '"{}"'
134139
replicas: 10
135140
template:
141+
metadata:
142+
annotations:
143+
app.kubernetes.io/managed-by: test-prefix
144+
key1: value1
145+
key2: value2
136146
spec:
137147
containers:
138148
- env:

0 commit comments

Comments
 (0)