@@ -53,8 +53,6 @@ func TestController(t *testing.T) {
53
53
}
54
54
claim := createClaim (claimName , claimNamespace , className )
55
55
otherClaim := createClaim (claimName , claimNamespace , otherClassName )
56
- delayedClaim := claim .DeepCopy ()
57
- delayedClaim .Spec .AllocationMode = resourceapi .AllocationModeWaitForFirstConsumer
58
56
podName := "pod"
59
57
podKey := "schedulingCtx:default/pod"
60
58
pod := createPod (podName , claimNamespace , nil )
@@ -148,94 +146,6 @@ func TestController(t *testing.T) {
148
146
classes : classes ,
149
147
claim : otherClaim ,
150
148
expectedClaim : otherClaim ,
151
- expectedError : errRequeue .Error (), // class might change
152
- },
153
- // Immediate allocation:
154
- // deletion time stamp set, our finalizer set, not allocated -> remove finalizer
155
- "immediate-deleted-finalizer-removal" : {
156
- key : claimKey ,
157
- classes : classes ,
158
- claim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
159
- driver : m .expectDeallocate (map [string ]error {claimName : nil }),
160
- expectedClaim : withDeletionTimestamp (claim ),
161
- },
162
- // deletion time stamp set, our finalizer set, not allocated, stopping fails -> requeue
163
- "immediate-deleted-finalizer-stop-failure" : {
164
- key : claimKey ,
165
- classes : classes ,
166
- claim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
167
- driver : m .expectDeallocate (map [string ]error {claimName : errors .New ("fake error" )}),
168
- expectedClaim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
169
- expectedError : "stop allocation: fake error" ,
170
- },
171
- // deletion time stamp set, other finalizer set, not allocated -> do nothing
172
- "immediate-deleted-finalizer-no-removal" : {
173
- key : claimKey ,
174
- classes : classes ,
175
- claim : withFinalizer (withDeletionTimestamp (claim ), otherFinalizer ),
176
- expectedClaim : withFinalizer (withDeletionTimestamp (claim ), otherFinalizer ),
177
- },
178
- // deletion time stamp set, finalizer set, allocated -> deallocate
179
- "immediate-deleted-allocated" : {
180
- key : claimKey ,
181
- classes : classes ,
182
- claim : withAllocate (withDeletionTimestamp (claim )),
183
- driver : m .expectDeallocate (map [string ]error {claimName : nil }),
184
- expectedClaim : withDeletionTimestamp (claim ),
185
- },
186
- // deletion time stamp set, finalizer set, allocated, deallocation fails -> requeue
187
- "immediate-deleted-deallocate-failure" : {
188
- key : claimKey ,
189
- classes : classes ,
190
- claim : withAllocate (withDeletionTimestamp (claim )),
191
- driver : m .expectDeallocate (map [string ]error {claimName : errors .New ("fake error" )}),
192
- expectedClaim : withAllocate (withDeletionTimestamp (claim )),
193
- expectedError : "deallocate: fake error" ,
194
- },
195
- // deletion time stamp set, finalizer not set -> do nothing
196
- "immediate-deleted-no-finalizer" : {
197
- key : claimKey ,
198
- classes : classes ,
199
- claim : withDeletionTimestamp (claim ),
200
- expectedClaim : withDeletionTimestamp (claim ),
201
- },
202
- // not deleted, not allocated, no finalizer -> add finalizer, allocate
203
- "immediate-do-allocation" : {
204
- key : claimKey ,
205
- classes : classes ,
206
- claim : claim ,
207
- driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
208
- expectClaimParameters (map [string ]interface {}{claimName : 2 }).
209
- expectAllocate (map [string ]allocate {claimName : {allocResult : & allocation , allocErr : nil }}),
210
- expectedClaim : withAllocate (claim ),
211
- },
212
- // not deleted, not allocated, finalizer -> allocate
213
- "immediate-continue-allocation" : {
214
- key : claimKey ,
215
- classes : classes ,
216
- claim : withFinalizer (claim , ourFinalizer ),
217
- driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
218
- expectClaimParameters (map [string ]interface {}{claimName : 2 }).
219
- expectAllocate (map [string ]allocate {claimName : {allocResult : & allocation , allocErr : nil }}),
220
- expectedClaim : withAllocate (claim ),
221
- },
222
- // not deleted, not allocated, finalizer, fail allocation -> requeue
223
- "immediate-fail-allocation" : {
224
- key : claimKey ,
225
- classes : classes ,
226
- claim : withFinalizer (claim , ourFinalizer ),
227
- driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
228
- expectClaimParameters (map [string ]interface {}{claimName : 2 }).
229
- expectAllocate (map [string ]allocate {claimName : {allocErr : errors .New ("fake error" )}}),
230
- expectedClaim : withFinalizer (claim , ourFinalizer ),
231
- expectedError : "allocate: fake error" ,
232
- },
233
- // not deleted, allocated -> do nothing
234
- "immediate-allocated-nop" : {
235
- key : claimKey ,
236
- classes : classes ,
237
- claim : withAllocate (claim ),
238
- expectedClaim : withAllocate (claim ),
239
149
},
240
150
241
151
// not deleted, reallocate -> deallocate
@@ -257,62 +167,60 @@ func TestController(t *testing.T) {
257
167
expectedError : "deallocate: fake error" ,
258
168
},
259
169
260
- // Delayed allocation is similar in some cases, but not quite
261
- // the same.
262
170
// deletion time stamp set, our finalizer set, not allocated -> remove finalizer
263
- "delayed- deleted-finalizer-removal" : {
171
+ "deleted-finalizer-removal" : {
264
172
key : claimKey ,
265
173
classes : classes ,
266
- claim : withFinalizer (withDeletionTimestamp (delayedClaim ), ourFinalizer ),
174
+ claim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
267
175
driver : m .expectDeallocate (map [string ]error {claimName : nil }),
268
- expectedClaim : withDeletionTimestamp (delayedClaim ),
176
+ expectedClaim : withDeletionTimestamp (claim ),
269
177
},
270
178
// deletion time stamp set, our finalizer set, not allocated, stopping fails -> requeue
271
- "delayed- deleted-finalizer-stop-failure" : {
179
+ "deleted-finalizer-stop-failure" : {
272
180
key : claimKey ,
273
181
classes : classes ,
274
- claim : withFinalizer (withDeletionTimestamp (delayedClaim ), ourFinalizer ),
182
+ claim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
275
183
driver : m .expectDeallocate (map [string ]error {claimName : errors .New ("fake error" )}),
276
- expectedClaim : withFinalizer (withDeletionTimestamp (delayedClaim ), ourFinalizer ),
184
+ expectedClaim : withFinalizer (withDeletionTimestamp (claim ), ourFinalizer ),
277
185
expectedError : "stop allocation: fake error" ,
278
186
},
279
187
// deletion time stamp set, other finalizer set, not allocated -> do nothing
280
- "delayed- deleted-finalizer-no-removal" : {
188
+ "deleted-finalizer-no-removal" : {
281
189
key : claimKey ,
282
190
classes : classes ,
283
- claim : withFinalizer (withDeletionTimestamp (delayedClaim ), otherFinalizer ),
284
- expectedClaim : withFinalizer (withDeletionTimestamp (delayedClaim ), otherFinalizer ),
191
+ claim : withFinalizer (withDeletionTimestamp (claim ), otherFinalizer ),
192
+ expectedClaim : withFinalizer (withDeletionTimestamp (claim ), otherFinalizer ),
285
193
},
286
194
// deletion time stamp set, finalizer set, allocated -> deallocate
287
- "delayed- deleted-allocated" : {
195
+ "deleted-allocated" : {
288
196
key : claimKey ,
289
197
classes : classes ,
290
- claim : withAllocate (withDeletionTimestamp (delayedClaim )),
198
+ claim : withAllocate (withDeletionTimestamp (claim )),
291
199
driver : m .expectDeallocate (map [string ]error {claimName : nil }),
292
- expectedClaim : withDeletionTimestamp (delayedClaim ),
200
+ expectedClaim : withDeletionTimestamp (claim ),
293
201
},
294
202
// deletion time stamp set, finalizer set, allocated, deallocation fails -> requeue
295
- "delayed- deleted-deallocate-failure" : {
203
+ "deleted-deallocate-failure" : {
296
204
key : claimKey ,
297
205
classes : classes ,
298
- claim : withAllocate (withDeletionTimestamp (delayedClaim )),
206
+ claim : withAllocate (withDeletionTimestamp (claim )),
299
207
driver : m .expectDeallocate (map [string ]error {claimName : errors .New ("fake error" )}),
300
- expectedClaim : withAllocate (withDeletionTimestamp (delayedClaim )),
208
+ expectedClaim : withAllocate (withDeletionTimestamp (claim )),
301
209
expectedError : "deallocate: fake error" ,
302
210
},
303
211
// deletion time stamp set, finalizer not set -> do nothing
304
- "delayed- deleted-no-finalizer" : {
212
+ "deleted-no-finalizer" : {
305
213
key : claimKey ,
306
214
classes : classes ,
307
- claim : withDeletionTimestamp (delayedClaim ),
308
- expectedClaim : withDeletionTimestamp (delayedClaim ),
215
+ claim : withDeletionTimestamp (claim ),
216
+ expectedClaim : withDeletionTimestamp (claim ),
309
217
},
310
218
// waiting for first consumer -> do nothing
311
- "delayed- pending" : {
219
+ "pending" : {
312
220
key : claimKey ,
313
221
classes : classes ,
314
- claim : delayedClaim ,
315
- expectedClaim : delayedClaim ,
222
+ claim : claim ,
223
+ expectedClaim : claim ,
316
224
},
317
225
318
226
// pod with no claims -> shouldn't occur, check again anyway
@@ -324,34 +232,23 @@ func TestController(t *testing.T) {
324
232
expectedError : errPeriodic .Error (),
325
233
},
326
234
327
- // pod with immediate allocation and selected node -> shouldn't occur, check again in case that claim changes
328
- "pod-immediate " : {
235
+ // no potential nodes -> shouldn't occur
236
+ "no-nodes " : {
329
237
key : podKey ,
238
+ classes : classes ,
330
239
claim : claim ,
331
240
expectedClaim : claim ,
332
241
pod : podWithClaim ,
333
- schedulingCtx : withSelectedNode (podSchedulingCtx ),
334
- expectedSchedulingCtx : withSelectedNode (podSchedulingCtx ),
335
- expectedError : errPeriodic .Error (),
336
- },
337
-
338
- // pod with delayed allocation, no potential nodes -> shouldn't occur
339
- "pod-delayed-no-nodes" : {
340
- key : podKey ,
341
- classes : classes ,
342
- claim : delayedClaim ,
343
- expectedClaim : delayedClaim ,
344
- pod : podWithClaim ,
345
242
schedulingCtx : podSchedulingCtx ,
346
243
expectedSchedulingCtx : podSchedulingCtx ,
347
244
},
348
245
349
- // pod with delayed allocation, potential nodes -> provide unsuitable nodes
350
- "pod-delayed- info" : {
246
+ // potential nodes -> provide unsuitable nodes
247
+ "info" : {
351
248
key : podKey ,
352
249
classes : classes ,
353
- claim : delayedClaim ,
354
- expectedClaim : delayedClaim ,
250
+ claim : claim ,
251
+ expectedClaim : claim ,
355
252
pod : podWithClaim ,
356
253
schedulingCtx : withPotentialNodes (podSchedulingCtx ),
357
254
driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
@@ -361,23 +258,23 @@ func TestController(t *testing.T) {
361
258
expectedError : errPeriodic .Error (),
362
259
},
363
260
364
- // pod with delayed allocation, potential nodes, selected node, missing class -> failure
365
- "pod-delayed- missing-class" : {
261
+ // potential nodes, selected node, missing class -> failure
262
+ "missing-class" : {
366
263
key : podKey ,
367
- claim : delayedClaim ,
368
- expectedClaim : delayedClaim ,
264
+ claim : claim ,
265
+ expectedClaim : claim ,
369
266
pod : podWithClaim ,
370
267
schedulingCtx : withSelectedNode (withPotentialNodes (podSchedulingCtx )),
371
268
expectedSchedulingCtx : withSelectedNode (withPotentialNodes (podSchedulingCtx )),
372
269
expectedError : `pod claim my-pod-claim: resourceclass.resource.k8s.io "mock-class" not found` ,
373
270
},
374
271
375
- // pod with delayed allocation, potential nodes, selected node -> allocate
376
- "pod-delayed- allocate" : {
272
+ // potential nodes, selected node -> allocate
273
+ "allocate" : {
377
274
key : podKey ,
378
275
classes : classes ,
379
- claim : delayedClaim ,
380
- expectedClaim : withReservedFor (withAllocate (delayedClaim ), pod ),
276
+ claim : claim ,
277
+ expectedClaim : withReservedFor (withAllocate (claim ), pod ),
381
278
pod : podWithClaim ,
382
279
schedulingCtx : withSelectedNode (withPotentialNodes (podSchedulingCtx )),
383
280
driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
@@ -387,12 +284,12 @@ func TestController(t *testing.T) {
387
284
expectedSchedulingCtx : withUnsuitableNodes (withSelectedNode (withPotentialNodes (podSchedulingCtx ))),
388
285
expectedError : errPeriodic .Error (),
389
286
},
390
- // pod with delayed allocation, potential nodes, selected node, all unsuitable -> update unsuitable nodes
391
- "pod-selected- is-potential-node" : {
287
+ // potential nodes, selected node, all unsuitable -> update unsuitable nodes
288
+ "is-potential-node" : {
392
289
key : podKey ,
393
290
classes : classes ,
394
- claim : delayedClaim ,
395
- expectedClaim : delayedClaim ,
291
+ claim : claim ,
292
+ expectedClaim : claim ,
396
293
pod : podWithClaim ,
397
294
schedulingCtx : withPotentialNodes (withSelectedNode (withPotentialNodes (podSchedulingCtx ))),
398
295
driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
@@ -401,12 +298,12 @@ func TestController(t *testing.T) {
401
298
expectedSchedulingCtx : withSpecificUnsuitableNodes (withSelectedNode (withPotentialNodes (podSchedulingCtx )), potentialNodes ),
402
299
expectedError : errPeriodic .Error (),
403
300
},
404
- // pod with delayed allocation, max potential nodes, other selected node, all unsuitable -> update unsuitable nodes with truncation at start
405
- "pod-selected- is-potential-node-truncate-first" : {
301
+ // max potential nodes, other selected node, all unsuitable -> update unsuitable nodes with truncation at start
302
+ "is-potential-node-truncate-first" : {
406
303
key : podKey ,
407
304
classes : classes ,
408
- claim : delayedClaim ,
409
- expectedClaim : delayedClaim ,
305
+ claim : claim ,
306
+ expectedClaim : claim ,
410
307
pod : podWithClaim ,
411
308
schedulingCtx : withSpecificPotentialNodes (withSelectedNode (withSpecificPotentialNodes (podSchedulingCtx , maxNodes )), maxNodes ),
412
309
driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
@@ -415,12 +312,12 @@ func TestController(t *testing.T) {
415
312
expectedSchedulingCtx : withSpecificUnsuitableNodes (withSelectedNode (withSpecificPotentialNodes (podSchedulingCtx , maxNodes )), append (maxNodes [1 :], nodeName )),
416
313
expectedError : errPeriodic .Error (),
417
314
},
418
- // pod with delayed allocation, max potential nodes, other selected node, all unsuitable (but in reverse order) -> update unsuitable nodes with truncation at end
315
+ // max potential nodes, other selected node, all unsuitable (but in reverse order) -> update unsuitable nodes with truncation at end
419
316
"pod-selected-is-potential-node-truncate-last" : {
420
317
key : podKey ,
421
318
classes : classes ,
422
- claim : delayedClaim ,
423
- expectedClaim : delayedClaim ,
319
+ claim : claim ,
320
+ expectedClaim : claim ,
424
321
pod : podWithClaim ,
425
322
schedulingCtx : withSpecificPotentialNodes (withSelectedNode (withSpecificPotentialNodes (podSchedulingCtx , maxNodes )), maxNodes ),
426
323
driver : m .expectClassParameters (map [string ]interface {}{className : 1 }).
@@ -652,7 +549,6 @@ func createClaim(claimName, claimNamespace, className string) *resourceapi.Resou
652
549
},
653
550
Spec : resourceapi.ResourceClaimSpec {
654
551
ResourceClassName : className ,
655
- AllocationMode : resourceapi .AllocationModeImmediate ,
656
552
},
657
553
}
658
554
}
0 commit comments