@@ -1532,3 +1532,265 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
1532
1532
})
1533
1533
}
1534
1534
}
1535
+
1536
+ func TestPluginsConfigurationCompatibility (t * testing.T ) {
1537
+ testcases := []struct {
1538
+ name string
1539
+ plugins config.Plugins
1540
+ wantPlugins map [string ][]config.Plugin
1541
+ }{
1542
+ {
1543
+ name : "No plugins specified" ,
1544
+ wantPlugins : map [string ][]config.Plugin {
1545
+ "QueueSortPlugin" : {
1546
+ {Name : "PrioritySort" },
1547
+ },
1548
+ "PreFilterPlugin" : {
1549
+ {Name : "NodeResourcesFit" },
1550
+ {Name : "NodePorts" },
1551
+ {Name : "InterPodAffinity" },
1552
+ {Name : "PodTopologySpread" },
1553
+ },
1554
+ "FilterPlugin" : {
1555
+ {Name : "NodeUnschedulable" },
1556
+ {Name : "NodeResourcesFit" },
1557
+ {Name : "NodeName" },
1558
+ {Name : "NodePorts" },
1559
+ {Name : "NodeAffinity" },
1560
+ {Name : "VolumeRestrictions" },
1561
+ {Name : "TaintToleration" },
1562
+ {Name : "EBSLimits" },
1563
+ {Name : "GCEPDLimits" },
1564
+ {Name : "NodeVolumeLimits" },
1565
+ {Name : "AzureDiskLimits" },
1566
+ {Name : "VolumeBinding" },
1567
+ {Name : "VolumeZone" },
1568
+ {Name : "InterPodAffinity" },
1569
+ {Name : "PodTopologySpread" },
1570
+ },
1571
+ "PreScorePlugin" : {
1572
+ {Name : "InterPodAffinity" },
1573
+ {Name : "DefaultPodTopologySpread" },
1574
+ {Name : "TaintToleration" },
1575
+ {Name : "PodTopologySpread" },
1576
+ },
1577
+ "ScorePlugin" : {
1578
+ {Name : "NodeResourcesBalancedAllocation" , Weight : 1 },
1579
+ {Name : "ImageLocality" , Weight : 1 },
1580
+ {Name : "InterPodAffinity" , Weight : 1 },
1581
+ {Name : "NodeResourcesLeastAllocated" , Weight : 1 },
1582
+ {Name : "NodeAffinity" , Weight : 1 },
1583
+ {Name : "NodePreferAvoidPods" , Weight : 10000 },
1584
+ {Name : "DefaultPodTopologySpread" , Weight : 1 },
1585
+ {Name : "TaintToleration" , Weight : 1 },
1586
+ {Name : "PodTopologySpread" , Weight : 1 },
1587
+ },
1588
+ "BindPlugin" : {{Name : "DefaultBinder" }},
1589
+ },
1590
+ },
1591
+ {
1592
+ name : "Disable some default plugins" ,
1593
+ plugins : config.Plugins {
1594
+ PreFilter : & config.PluginSet {
1595
+ Disabled : []config.Plugin {
1596
+ {Name : "NodeResourcesFit" },
1597
+ {Name : "NodePorts" },
1598
+ {Name : "InterPodAffinity" },
1599
+ {Name : "PodTopologySpread" },
1600
+ },
1601
+ },
1602
+ Filter : & config.PluginSet {
1603
+ Disabled : []config.Plugin {
1604
+ {Name : "NodeUnschedulable" },
1605
+ {Name : "NodeResourcesFit" },
1606
+ {Name : "NodeName" },
1607
+ {Name : "NodePorts" },
1608
+ {Name : "NodeAffinity" },
1609
+ {Name : "VolumeRestrictions" },
1610
+ {Name : "TaintToleration" },
1611
+ {Name : "EBSLimits" },
1612
+ {Name : "GCEPDLimits" },
1613
+ {Name : "NodeVolumeLimits" },
1614
+ {Name : "AzureDiskLimits" },
1615
+ {Name : "VolumeBinding" },
1616
+ {Name : "VolumeZone" },
1617
+ {Name : "InterPodAffinity" },
1618
+ {Name : "PodTopologySpread" },
1619
+ },
1620
+ },
1621
+ PreScore : & config.PluginSet {
1622
+ Disabled : []config.Plugin {
1623
+ {Name : "InterPodAffinity" },
1624
+ {Name : "DefaultPodTopologySpread" },
1625
+ {Name : "TaintToleration" },
1626
+ {Name : "PodTopologySpread" },
1627
+ },
1628
+ },
1629
+ Score : & config.PluginSet {
1630
+ Disabled : []config.Plugin {
1631
+ {Name : "NodeResourcesBalancedAllocation" },
1632
+ {Name : "ImageLocality" },
1633
+ {Name : "InterPodAffinity" },
1634
+ {Name : "NodeResourcesLeastAllocated" },
1635
+ {Name : "NodeAffinity" },
1636
+ {Name : "NodePreferAvoidPods" },
1637
+ {Name : "DefaultPodTopologySpread" },
1638
+ {Name : "TaintToleration" },
1639
+ {Name : "PodTopologySpread" },
1640
+ },
1641
+ },
1642
+ },
1643
+ wantPlugins : map [string ][]config.Plugin {
1644
+ "QueueSortPlugin" : {
1645
+ {Name : "PrioritySort" },
1646
+ },
1647
+ "BindPlugin" : {{Name : "DefaultBinder" }},
1648
+ },
1649
+ },
1650
+ {
1651
+ name : "Reverse default plugins order with changing score weight" ,
1652
+ plugins : config.Plugins {
1653
+ QueueSort : & config.PluginSet {
1654
+ Enabled : []config.Plugin {
1655
+ {Name : "PrioritySort" },
1656
+ },
1657
+ Disabled : []config.Plugin {
1658
+ {Name : "*" },
1659
+ },
1660
+ },
1661
+ PreFilter : & config.PluginSet {
1662
+ Enabled : []config.Plugin {
1663
+ {Name : "InterPodAffinity" },
1664
+ {Name : "NodePorts" },
1665
+ {Name : "NodeResourcesFit" },
1666
+ },
1667
+ Disabled : []config.Plugin {
1668
+ {Name : "*" },
1669
+ },
1670
+ },
1671
+ Filter : & config.PluginSet {
1672
+ Enabled : []config.Plugin {
1673
+ {Name : "InterPodAffinity" },
1674
+ {Name : "VolumeZone" },
1675
+ {Name : "VolumeBinding" },
1676
+ {Name : "AzureDiskLimits" },
1677
+ {Name : "NodeVolumeLimits" },
1678
+ {Name : "GCEPDLimits" },
1679
+ {Name : "EBSLimits" },
1680
+ {Name : "TaintToleration" },
1681
+ {Name : "VolumeRestrictions" },
1682
+ {Name : "NodeAffinity" },
1683
+ {Name : "NodePorts" },
1684
+ {Name : "NodeName" },
1685
+ {Name : "NodeResourcesFit" },
1686
+ {Name : "NodeUnschedulable" },
1687
+ },
1688
+ Disabled : []config.Plugin {
1689
+ {Name : "*" },
1690
+ },
1691
+ },
1692
+ PreScore : & config.PluginSet {
1693
+ Enabled : []config.Plugin {
1694
+ {Name : "TaintToleration" },
1695
+ {Name : "DefaultPodTopologySpread" },
1696
+ {Name : "InterPodAffinity" },
1697
+ },
1698
+ Disabled : []config.Plugin {
1699
+ {Name : "*" },
1700
+ },
1701
+ },
1702
+ Score : & config.PluginSet {
1703
+ Enabled : []config.Plugin {
1704
+ {Name : "TaintToleration" , Weight : 24 },
1705
+ {Name : "DefaultPodTopologySpread" , Weight : 24 },
1706
+ {Name : "NodePreferAvoidPods" , Weight : 24 },
1707
+ {Name : "NodeAffinity" , Weight : 24 },
1708
+ {Name : "NodeResourcesLeastAllocated" , Weight : 24 },
1709
+ {Name : "InterPodAffinity" , Weight : 24 },
1710
+ {Name : "ImageLocality" , Weight : 24 },
1711
+ {Name : "NodeResourcesBalancedAllocation" , Weight : 24 },
1712
+ },
1713
+ Disabled : []config.Plugin {
1714
+ {Name : "*" },
1715
+ },
1716
+ },
1717
+ Bind : & config.PluginSet {
1718
+ Enabled : []config.Plugin {{Name : "DefaultBinder" }},
1719
+ Disabled : []config.Plugin {{Name : "*" }},
1720
+ },
1721
+ },
1722
+ wantPlugins : map [string ][]config.Plugin {
1723
+ "QueueSortPlugin" : {
1724
+ {Name : "PrioritySort" },
1725
+ },
1726
+ "PreFilterPlugin" : {
1727
+ {Name : "InterPodAffinity" },
1728
+ {Name : "NodePorts" },
1729
+ {Name : "NodeResourcesFit" },
1730
+ },
1731
+ "FilterPlugin" : {
1732
+ {Name : "InterPodAffinity" },
1733
+ {Name : "VolumeZone" },
1734
+ {Name : "VolumeBinding" },
1735
+ {Name : "AzureDiskLimits" },
1736
+ {Name : "NodeVolumeLimits" },
1737
+ {Name : "GCEPDLimits" },
1738
+ {Name : "EBSLimits" },
1739
+ {Name : "TaintToleration" },
1740
+ {Name : "VolumeRestrictions" },
1741
+ {Name : "NodeAffinity" },
1742
+ {Name : "NodePorts" },
1743
+ {Name : "NodeName" },
1744
+ {Name : "NodeResourcesFit" },
1745
+ {Name : "NodeUnschedulable" },
1746
+ },
1747
+ "PreScorePlugin" : {
1748
+ {Name : "TaintToleration" },
1749
+ {Name : "DefaultPodTopologySpread" },
1750
+ {Name : "InterPodAffinity" },
1751
+ },
1752
+ "ScorePlugin" : {
1753
+ {Name : "TaintToleration" , Weight : 24 },
1754
+ {Name : "DefaultPodTopologySpread" , Weight : 24 },
1755
+ {Name : "NodePreferAvoidPods" , Weight : 24 },
1756
+ {Name : "NodeAffinity" , Weight : 24 },
1757
+ {Name : "NodeResourcesLeastAllocated" , Weight : 24 },
1758
+ {Name : "InterPodAffinity" , Weight : 24 },
1759
+ {Name : "ImageLocality" , Weight : 24 },
1760
+ {Name : "NodeResourcesBalancedAllocation" , Weight : 24 },
1761
+ },
1762
+ "BindPlugin" : {{Name : "DefaultBinder" }},
1763
+ },
1764
+ },
1765
+ }
1766
+ for _ , tc := range testcases {
1767
+ t .Run (tc .name , func (t * testing.T ) {
1768
+
1769
+ client := fake .NewSimpleClientset ()
1770
+ informerFactory := informers .NewSharedInformerFactory (client , 0 )
1771
+ recorderFactory := profile .NewRecorderFactory (events .NewBroadcaster (& events.EventSinkImpl {Interface : client .EventsV1beta1 ().Events ("" )}))
1772
+
1773
+ sched , err := scheduler .New (
1774
+ client ,
1775
+ informerFactory ,
1776
+ informerFactory .Core ().V1 ().Pods (),
1777
+ recorderFactory ,
1778
+ make (chan struct {}),
1779
+ scheduler .WithProfiles (config.KubeSchedulerProfile {
1780
+ SchedulerName : v1 .DefaultSchedulerName ,
1781
+ Plugins : & tc .plugins ,
1782
+ }),
1783
+ )
1784
+
1785
+ if err != nil {
1786
+ t .Fatalf ("Error constructing: %v" , err )
1787
+ }
1788
+
1789
+ defProf := sched .Profiles ["default-scheduler" ]
1790
+ gotPlugins := defProf .ListPlugins ()
1791
+ if diff := cmp .Diff (tc .wantPlugins , gotPlugins ); diff != "" {
1792
+ t .Errorf ("unexpected plugins diff (-want, +got): %s" , diff )
1793
+ }
1794
+ })
1795
+ }
1796
+ }
0 commit comments