Repository navigation
Expand file tree
/
Copy pathchainsaw-test.yaml
More file actions
331 lines (330 loc) · 12.7 KB
/
Copy pathchainsaw-test.yaml
File metadata and controls
331 lines (330 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: spark-operator-kueue-pods-ready
spec:
namespace: default
steps:
- name: spark-cluster-whose-pods-are-not-ready-is-evicted-by-kueue
# Each step uses its own queue objects, so that a step never waits for Kueue to finish
# deleting the objects of another step.
bindings:
- name: FLAVOR
value: spark-e2e-pods-ready-flavor
- name: CLUSTER_QUEUE
value: spark-e2e-pods-ready-cluster-queue
- name: LOCAL_QUEUE
value: spark-e2e-pods-ready-queue
try:
# The eviction below needs the waitForPodsReady timeout which the CI shortens to 2 minutes,
# rather than the default of 30 minutes.
- script:
timeout: 30s
content: |
kubectl get configmap kueue-manager-config -n kueue-system -o json \
| jq -r '.data["controller_manager_config.yaml"] | if contains("\nwaitForPodsReady:\n timeout: 2m\n") then "SHORTENED" else "DEFAULT" end'
check:
(contains($stdout, 'SHORTENED')): true
- apply:
file: ../kueue/kueue-queues.yaml
# The quota fits both clusters (1 CPU for each master and worker)
- script:
timeout: 30s
env:
- name: CLUSTER_QUEUE
value: ($CLUSTER_QUEUE)
content: |
kubectl patch clusterqueue "$CLUSTER_QUEUE" --type json -p \
'[{"op": "replace", "path": "/spec/resourceGroups/0/flavors/0/resources/0/nominalQuota", "value": "4"},
{"op": "replace", "path": "/spec/resourceGroups/0/flavors/0/resources/1/nominalQuota", "value": "8Gi"}]'
- apply:
file: spark-cluster-example-pods-ready.yaml
- assert:
timeout: 60s
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkcluster-spark-cluster-kueue-pods-ready-test
namespace: default
status:
(conditions[?type == 'Admitted' && status == 'True'] | length(@)): 1
# The node labels and tolerations of the assigned ResourceFlavor are injected into the master
# and the worker pods.
- assert:
timeout: 5m
resource:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: spark-cluster-kueue-pods-ready-test-master
namespace: default
spec:
template:
spec:
nodeSelector:
kubernetes.io/os: linux
(tolerations[?key == 'spark.apache.org/kueue-e2e'] | length(@)): 1
- assert:
timeout: 5m
resource:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: spark-cluster-kueue-pods-ready-test-worker
namespace: default
spec:
template:
spec:
nodeSelector:
kubernetes.io/os: linux
(tolerations[?key == 'spark.apache.org/kueue-e2e'] | length(@)): 1
# Admitted after the cluster above, so that the waitForPodsReady timeout of Kueue, which the CI
# shortens to 2 minutes, has elapsed for both clusters once this one is evicted.
- apply:
file: spark-cluster-example-pods-not-ready.yaml
# RunningHealthy does not wait for the master and the worker, so the operator reports that they
# are ready once they are.
- assert:
timeout: 5m
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkcluster-spark-cluster-kueue-pods-ready-test
namespace: default
status:
(conditions[?type == 'PodsReady' && status == 'True' && reason == 'Started'] | length(@)): 1
- assert:
timeout: 5m
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkcluster-spark-cluster-kueue-pods-not-ready-test
namespace: default
status:
(conditions[?type == 'Evicted' && status == 'True' && reason == 'PodsReadyTimeout'] | length(@)): 1
# Like on a preemption, the operator releases the master and worker first and then the Workload
# once its requeue backoff, which the CI shortens to 10 seconds, elapses, and the cluster is
# queued again.
- assert:
timeout: 60s
resource:
apiVersion: v1
kind: Event
metadata:
namespace: default
involvedObject:
kind: SparkCluster
name: spark-cluster-kueue-pods-not-ready-test
reason: Suspended
(contains(message || '', 'evicted by Kueue')): true
(contains(message || '', 'PodsReadyTimeout')): true
- assert:
timeout: 5m
resource:
apiVersion: v1
kind: Event
metadata:
namespace: default
involvedObject:
kind: SparkCluster
name: spark-cluster-kueue-pods-not-ready-test
reason: Submitted
(contains(message || '', 'after its eviction')): true
# The cluster whose master and worker are ready is not evicted
- assert:
timeout: 30s
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkcluster-spark-cluster-kueue-pods-ready-test
namespace: default
status:
(conditions[?type == 'Evicted' && status == 'True'] | length(@)): 0
# Nor was it evicted before, which the check above misses once the evicted Workload is replaced
# by a new one of the same name
- error:
timeout: 10s
resource:
apiVersion: v1
kind: Event
metadata:
namespace: default
involvedObject:
kind: SparkCluster
name: spark-cluster-kueue-pods-ready-test
reason: Suspended
catch:
- describe:
apiVersion: spark.apache.org/v1
kind: SparkCluster
namespace: default
- describe:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
namespace: default
- events:
namespace: default
finally:
- script:
timeout: 120s
env:
- name: FLAVOR
value: ($FLAVOR)
- name: CLUSTER_QUEUE
value: ($CLUSTER_QUEUE)
- name: LOCAL_QUEUE
value: ($LOCAL_QUEUE)
content: |
kubectl delete sparkcluster spark-cluster-kueue-pods-ready-test spark-cluster-kueue-pods-not-ready-test -n default --ignore-not-found=true
# Kueue finalizers may delay the deletion, which later steps do not depend on.
kubectl delete localqueue "$LOCAL_QUEUE" -n default --ignore-not-found=true --wait=false
kubectl delete clusterqueue "$CLUSTER_QUEUE" --ignore-not-found=true --wait=false
kubectl delete resourceflavor "$FLAVOR" --ignore-not-found=true --wait=false
- name: spark-application-whose-executors-are-not-ready-is-evicted-by-kueue
# Each step uses its own queue objects, so that a step never waits for Kueue to finish
# deleting the objects of another step.
bindings:
- name: FLAVOR
value: spark-e2e-app-pods-ready-flavor
- name: CLUSTER_QUEUE
value: spark-e2e-app-pods-ready-cluster-queue
- name: LOCAL_QUEUE
value: spark-e2e-app-pods-ready-queue
try:
# The eviction below needs the waitForPodsReady timeout which the CI shortens to 2 minutes,
# rather than the default of 30 minutes.
- script:
timeout: 30s
content: |
kubectl get configmap kueue-manager-config -n kueue-system -o json \
| jq -r '.data["controller_manager_config.yaml"] | if contains("\nwaitForPodsReady:\n timeout: 2m\n") then "SHORTENED" else "DEFAULT" end'
check:
(contains($stdout, 'SHORTENED')): true
- apply:
file: ../kueue/kueue-queues.yaml
# The quota fits the application (1 CPU for the driver and 1 for the executor)
- script:
timeout: 30s
env:
- name: CLUSTER_QUEUE
value: ($CLUSTER_QUEUE)
content: |
kubectl patch clusterqueue "$CLUSTER_QUEUE" --type json -p \
'[{"op": "replace", "path": "/spec/resourceGroups/0/flavors/0/resources/0/nominalQuota", "value": "2"},
{"op": "replace", "path": "/spec/resourceGroups/0/flavors/0/resources/1/nominalQuota", "value": "8Gi"}]'
- apply:
file: spark-example-executors-not-ready.yaml
- assert:
timeout: 5m
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkapplication-spark-job-kueue-executors-not-ready-test
namespace: default
status:
(conditions[?type == 'Evicted' && status == 'True' && reason == 'PodsReadyTimeout'] | length(@)): 1
# Like a running SparkCluster, the operator releases the driver and executor first and then the
# Workload once its requeue backoff, which the CI shortens to 10 seconds, elapses, and the
# application is queued again with a new attempt.
- assert:
timeout: 60s
resource:
apiVersion: v1
kind: Event
metadata:
namespace: default
involvedObject:
kind: SparkApplication
name: spark-job-kueue-executors-not-ready-test
reason: Suspended
(contains(message || '', 'evicted by Kueue')): true
(contains(message || '', 'PodsReadyTimeout')): true
- assert:
timeout: 5m
resource:
apiVersion: v1
kind: Event
metadata:
namespace: default
involvedObject:
kind: SparkApplication
name: spark-job-kueue-executors-not-ready-test
reason: Submitted
(contains(message || '', 'after its eviction')): true
# The new attempt does not count as a restart, even with the default restartPolicy Never, and
# runs again on the quota which Kueue admits its new Workload into. It is evicted again once the
# waitForPodsReady timeout elapses, since its executor is never scheduled.
- assert:
timeout: 5m
resource:
apiVersion: spark.apache.org/v1
kind: SparkApplication
metadata:
name: spark-job-kueue-executors-not-ready-test
namespace: default
status:
currentState:
currentStateSummary: RunningHealthy
currentAttemptSummary:
attemptInfo:
id: 1
restartCounter: 0
- assert:
timeout: 60s
resource:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
metadata:
name: sparkapplication-spark-job-kueue-executors-not-ready-test
namespace: default
status:
(conditions[?type == 'Admitted' && status == 'True'] | length(@)): 1
(conditions[?type == 'Evicted' && status == 'True'] | length(@)): 0
catch:
- describe:
apiVersion: spark.apache.org/v1
kind: SparkApplication
namespace: default
- describe:
apiVersion: kueue.x-k8s.io/v1beta2
kind: Workload
namespace: default
- events:
namespace: default
finally:
- script:
timeout: 120s
env:
- name: FLAVOR
value: ($FLAVOR)
- name: CLUSTER_QUEUE
value: ($CLUSTER_QUEUE)
- name: LOCAL_QUEUE
value: ($LOCAL_QUEUE)
content: |
kubectl delete sparkapplication spark-job-kueue-executors-not-ready-test -n default --ignore-not-found=true
# Kueue finalizers may delay the deletion, which later steps do not depend on.
kubectl delete localqueue "$LOCAL_QUEUE" -n default --ignore-not-found=true --wait=false
kubectl delete clusterqueue "$CLUSTER_QUEUE" --ignore-not-found=true --wait=false
kubectl delete resourceflavor "$FLAVOR" --ignore-not-found=true --wait=false