@@ -21,9 +21,8 @@ import (
21
21
"reflect"
22
22
"testing"
23
23
24
- "k8s.io/api/core/v1"
24
+ v1 "k8s.io/api/core/v1"
25
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26
- schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
27
26
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
28
27
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
29
28
st "k8s.io/kubernetes/pkg/scheduler/testing"
@@ -295,7 +294,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
295
294
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgIndia }},
296
295
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelAzAz1 }},
297
296
},
298
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : 0 }, {Name : "machine3" , Score : 0 }},
297
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : 0 }, {Name : "machine3" , Score : 0 }},
299
298
name : "Affinity: pod that matches topology key & pods in nodes will get high score comparing to others" +
300
299
"which doesn't match either pods in nodes or in topology key" ,
301
300
},
@@ -313,7 +312,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
313
312
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgChinaAzAz1 }},
314
313
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelRgIndia }},
315
314
},
316
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : schedulerapi . MaxPriority }, {Name : "machine3" , Score : 0 }},
315
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : framework . MaxNodeScore }, {Name : "machine3" , Score : 0 }},
317
316
name : "All the nodes that have the same topology key & label value with one of them has an existing pod that match the affinity rules, have the same score" ,
318
317
},
319
318
// there are 2 regions, say regionChina(machine1,machine3,machine4) and regionIndia(machine2,machine5), both regions have nodes that match the preference.
@@ -337,7 +336,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
337
336
{ObjectMeta : metav1.ObjectMeta {Name : "machine4" , Labels : labelRgChina }},
338
337
{ObjectMeta : metav1.ObjectMeta {Name : "machine5" , Labels : labelRgIndia }},
339
338
},
340
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : 5 }, {Name : "machine3" , Score : schedulerapi . MaxPriority }, {Name : "machine4" , Score : schedulerapi . MaxPriority }, {Name : "machine5" , Score : 5 }},
339
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : 5 }, {Name : "machine3" , Score : framework . MaxNodeScore }, {Name : "machine4" , Score : framework . MaxNodeScore }, {Name : "machine5" , Score : 5 }},
341
340
name : "Affinity: nodes in one region has more matching pods comparing to other reqion, so the region which has more macthes will get high score" ,
342
341
},
343
342
// Test with the different operators and values for pod affinity scheduling preference, including some match failures.
@@ -353,7 +352,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
353
352
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgIndia }},
354
353
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelAzAz1 }},
355
354
},
356
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 2 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }, {Name : "machine3" , Score : 0 }},
355
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 2 }, {Name : "machine2" , Score : framework . MaxNodeScore }, {Name : "machine3" , Score : 0 }},
357
356
name : "Affinity: different Label operators and values for pod affinity scheduling preference, including some match failures " ,
358
357
},
359
358
// Test the symmetry cases for affinity, the difference between affinity and symmetry is not the pod wants to run together with some existing pods,
@@ -369,7 +368,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
369
368
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgIndia }},
370
369
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelAzAz1 }},
371
370
},
372
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }, {Name : "machine3" , Score : 0 }},
371
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : framework . MaxNodeScore }, {Name : "machine3" , Score : 0 }},
373
372
name : "Affinity symmetry: considred only the preferredDuringSchedulingIgnoredDuringExecution in pod affinity symmetry" ,
374
373
},
375
374
{
@@ -383,7 +382,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
383
382
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgIndia }},
384
383
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelAzAz1 }},
385
384
},
386
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : schedulerapi . MaxPriority }, {Name : "machine3" , Score : 0 }},
385
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : framework . MaxNodeScore }, {Name : "machine3" , Score : 0 }},
387
386
name : "Affinity symmetry: considred RequiredDuringSchedulingIgnoredDuringExecution in pod affinity symmetry" ,
388
387
},
389
388
@@ -403,7 +402,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
403
402
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelAzAz1 }},
404
403
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgChina }},
405
404
},
406
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }},
405
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : framework . MaxNodeScore }},
407
406
name : "Anti Affinity: pod that doesnot match existing pods in node will get high score " ,
408
407
},
409
408
{
@@ -416,7 +415,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
416
415
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelAzAz1 }},
417
416
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgChina }},
418
417
},
419
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }},
418
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : framework . MaxNodeScore }},
420
419
name : "Anti Affinity: pod that does not matches topology key & matches the pods in nodes will get higher score comparing to others " ,
421
420
},
422
421
{
@@ -430,7 +429,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
430
429
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelAzAz1 }},
431
430
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgIndia }},
432
431
},
433
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }},
432
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : framework . MaxNodeScore }},
434
433
name : "Anti Affinity: one node has more matching pods comparing to other node, so the node which has more unmacthes will get high score" ,
435
434
},
436
435
// Test the symmetry cases for anti affinity
@@ -444,7 +443,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
444
443
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelAzAz1 }},
445
444
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelAzAz2 }},
446
445
},
447
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : schedulerapi . MaxPriority }},
446
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : 0 }, {Name : "machine2" , Score : framework . MaxNodeScore }},
448
447
name : "Anti Affinity symmetry: the existing pods in node which has anti affinity match will get high score" ,
449
448
},
450
449
// Test both affinity and anti-affinity
@@ -458,7 +457,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
458
457
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelRgChina }},
459
458
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelAzAz1 }},
460
459
},
461
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : 0 }},
460
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : 0 }},
462
461
name : "Affinity and Anti Affinity: considered only preferredDuringSchedulingIgnoredDuringExecution in both pod affinity & anti affinity" ,
463
462
},
464
463
// Combined cases considering both affinity and anti-affinity, the pod to schedule and existing pods have the same labels (they are in the same RC/service),
@@ -483,7 +482,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
483
482
{ObjectMeta : metav1.ObjectMeta {Name : "machine4" , Labels : labelRgChina }},
484
483
{ObjectMeta : metav1.ObjectMeta {Name : "machine5" , Labels : labelRgIndia }},
485
484
},
486
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : 4 }, {Name : "machine3" , Score : schedulerapi . MaxPriority }, {Name : "machine4" , Score : schedulerapi . MaxPriority }, {Name : "machine5" , Score : 4 }},
485
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : 4 }, {Name : "machine3" , Score : framework . MaxNodeScore }, {Name : "machine4" , Score : framework . MaxNodeScore }, {Name : "machine5" , Score : 4 }},
487
486
name : "Affinity and Anti Affinity: considering both affinity and anti-affinity, the pod to schedule and existing pods have the same labels" ,
488
487
},
489
488
// Consider Affinity, Anti Affinity and symmetry together.
@@ -505,7 +504,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
505
504
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelRgIndia }},
506
505
{ObjectMeta : metav1.ObjectMeta {Name : "machine4" , Labels : labelAzAz2 }},
507
506
},
508
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : 0 }, {Name : "machine3" , Score : schedulerapi . MaxPriority }, {Name : "machine4" , Score : 0 }},
507
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : 0 }, {Name : "machine3" , Score : framework . MaxNodeScore }, {Name : "machine4" , Score : 0 }},
509
508
name : "Affinity and Anti Affinity and symmetry: considered only preferredDuringSchedulingIgnoredDuringExecution in both pod affinity & anti affinity & symmetry" ,
510
509
},
511
510
// Cover https://github.com/kubernetes/kubernetes/issues/82796 which panics upon:
@@ -521,7 +520,7 @@ func TestInterPodAffinityPriority(t *testing.T) {
521
520
{ObjectMeta : metav1.ObjectMeta {Name : "machine1" , Labels : labelRgChina }},
522
521
{ObjectMeta : metav1.ObjectMeta {Name : "machine2" , Labels : labelRgChina }},
523
522
},
524
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : schedulerapi . MaxPriority }},
523
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : framework . MaxNodeScore }},
525
524
name : "Avoid panic when partial nodes in a topology don't have pods with affinity" ,
526
525
},
527
526
}
@@ -594,7 +593,7 @@ func TestHardPodAffinitySymmetricWeight(t *testing.T) {
594
593
{ObjectMeta : metav1.ObjectMeta {Name : "machine3" , Labels : labelAzAz1 }},
595
594
},
596
595
hardPodAffinityWeight : v1 .DefaultHardPodAffinitySymmetricWeight ,
597
- expectedList : []framework.NodeScore {{Name : "machine1" , Score : schedulerapi . MaxPriority }, {Name : "machine2" , Score : schedulerapi . MaxPriority }, {Name : "machine3" , Score : 0 }},
596
+ expectedList : []framework.NodeScore {{Name : "machine1" , Score : framework . MaxNodeScore }, {Name : "machine2" , Score : framework . MaxNodeScore }, {Name : "machine3" , Score : 0 }},
598
597
name : "Hard Pod Affinity symmetry: hard pod affinity symmetry weights 1 by default, then nodes that match the hard pod affinity symmetry rules, get a high score" ,
599
598
},
600
599
{
0 commit comments