compatibility_test.go 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package testing
  14. import (
  15. "testing"
  16. "github.com/google/go-cmp/cmp"
  17. v1 "k8s.io/api/core/v1"
  18. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  19. utilfeature "k8s.io/apiserver/pkg/util/feature"
  20. "k8s.io/client-go/informers"
  21. "k8s.io/client-go/kubernetes/fake"
  22. "k8s.io/component-base/featuregate"
  23. featuregatetesting "k8s.io/component-base/featuregate/testing"
  24. _ "k8s.io/kubernetes/pkg/apis/core/install"
  25. "k8s.io/kubernetes/pkg/features"
  26. "k8s.io/kubernetes/pkg/scheduler"
  27. "k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
  28. "k8s.io/kubernetes/pkg/scheduler/apis/config"
  29. "k8s.io/kubernetes/pkg/scheduler/core"
  30. )
  31. type testCase struct {
  32. name string
  33. JSON string
  34. featureGates map[featuregate.Feature]bool
  35. wantPlugins map[string][]config.Plugin
  36. wantExtenders []config.Extender
  37. }
  38. func TestCompatibility_v1_Scheduler(t *testing.T) {
  39. // Add serialized versions of scheduler config that exercise available options to ensure compatibility between releases
  40. testcases := []testCase{
  41. // This is a special test for the "composite" predicate "GeneralPredicate". GeneralPredicate is a combination
  42. // of predicates, and here we test that if given, it is mapped to the set of plugins that should be executed.
  43. {
  44. name: "GeneralPredicate",
  45. JSON: `{
  46. "kind": "Policy",
  47. "apiVersion": "v1",
  48. "predicates": [
  49. {"name": "GeneralPredicates"}
  50. ],
  51. "priorities": [
  52. ]
  53. }`,
  54. wantPlugins: map[string][]config.Plugin{
  55. "QueueSortPlugin": {{Name: "PrioritySort"}},
  56. "PreFilterPlugin": {
  57. {Name: "NodeResourcesFit"},
  58. {Name: "NodePorts"},
  59. },
  60. "FilterPlugin": {
  61. {Name: "NodeUnschedulable"},
  62. {Name: "NodeResourcesFit"},
  63. {Name: "NodeName"},
  64. {Name: "NodePorts"},
  65. {Name: "NodeAffinity"},
  66. {Name: "TaintToleration"},
  67. },
  68. "BindPlugin": {{Name: "DefaultBinder"}},
  69. },
  70. },
  71. // This is a special test for the case where a policy is specified without specifying any filters.
  72. {
  73. name: "MandatoryFilters",
  74. JSON: `{
  75. "kind": "Policy",
  76. "apiVersion": "v1",
  77. "predicates": [
  78. ],
  79. "priorities": [
  80. ]
  81. }`,
  82. wantPlugins: map[string][]config.Plugin{
  83. "QueueSortPlugin": {{Name: "PrioritySort"}},
  84. "FilterPlugin": {
  85. {Name: "NodeUnschedulable"},
  86. {Name: "TaintToleration"},
  87. },
  88. "BindPlugin": {{Name: "DefaultBinder"}},
  89. },
  90. },
  91. // Do not change this JSON after the corresponding release has been tagged.
  92. // A failure indicates backwards compatibility with the specified release was broken.
  93. {
  94. name: "1.0",
  95. JSON: `{
  96. "kind": "Policy",
  97. "apiVersion": "v1",
  98. "predicates": [
  99. {"name": "MatchNodeSelector"},
  100. {"name": "PodFitsResources"},
  101. {"name": "PodFitsPorts"},
  102. {"name": "NoDiskConflict"},
  103. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  104. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  105. ],"priorities": [
  106. {"name": "LeastRequestedPriority", "weight": 1},
  107. {"name": "ServiceSpreadingPriority", "weight": 2},
  108. {"name": "TestServiceAntiAffinity", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  109. {"name": "TestLabelPreference", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}}
  110. ]
  111. }`,
  112. wantPlugins: map[string][]config.Plugin{
  113. "QueueSortPlugin": {{Name: "PrioritySort"}},
  114. "PreFilterPlugin": {
  115. {Name: "NodePorts"},
  116. {Name: "NodeResourcesFit"},
  117. {Name: "ServiceAffinity"},
  118. },
  119. "FilterPlugin": {
  120. {Name: "NodeUnschedulable"},
  121. {Name: "NodePorts"},
  122. {Name: "NodeAffinity"},
  123. {Name: "NodeResourcesFit"},
  124. {Name: "VolumeRestrictions"},
  125. {Name: "TaintToleration"},
  126. {Name: "NodeLabel"},
  127. {Name: "ServiceAffinity"},
  128. },
  129. "PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
  130. "ScorePlugin": {
  131. {Name: "NodeResourcesLeastAllocated", Weight: 1},
  132. {Name: "NodeLabel", Weight: 4},
  133. {Name: "DefaultPodTopologySpread", Weight: 2},
  134. {Name: "ServiceAffinity", Weight: 3},
  135. },
  136. "BindPlugin": {{Name: "DefaultBinder"}},
  137. },
  138. },
  139. // Do not change this JSON after the corresponding release has been tagged.
  140. // A failure indicates backwards compatibility with the specified release was broken.
  141. {
  142. name: "1.1",
  143. JSON: `{
  144. "kind": "Policy",
  145. "apiVersion": "v1",
  146. "predicates": [
  147. {"name": "MatchNodeSelector"},
  148. {"name": "PodFitsHostPorts"},
  149. {"name": "PodFitsResources"},
  150. {"name": "NoDiskConflict"},
  151. {"name": "HostName"},
  152. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  153. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  154. ],"priorities": [
  155. {"name": "EqualPriority", "weight": 2},
  156. {"name": "LeastRequestedPriority", "weight": 2},
  157. {"name": "BalancedResourceAllocation", "weight": 2},
  158. {"name": "SelectorSpreadPriority", "weight": 2},
  159. {"name": "TestServiceAntiAffinity1", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  160. {"name": "TestServiceAntiAffinity2", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "region"}}},
  161. {"name": "TestLabelPreference1", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}},
  162. {"name": "TestLabelPreference2", "weight": 4, "argument": {"labelPreference": {"label": "foo", "presence":false}}}
  163. ]
  164. }`,
  165. wantPlugins: map[string][]config.Plugin{
  166. "QueueSortPlugin": {{Name: "PrioritySort"}},
  167. "PreFilterPlugin": {
  168. {Name: "NodePorts"},
  169. {Name: "NodeResourcesFit"},
  170. {Name: "ServiceAffinity"},
  171. },
  172. "FilterPlugin": {
  173. {Name: "NodeUnschedulable"},
  174. {Name: "NodeName"},
  175. {Name: "NodePorts"},
  176. {Name: "NodeAffinity"},
  177. {Name: "NodeResourcesFit"},
  178. {Name: "VolumeRestrictions"},
  179. {Name: "TaintToleration"},
  180. {Name: "NodeLabel"},
  181. {Name: "ServiceAffinity"},
  182. },
  183. "PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
  184. "ScorePlugin": {
  185. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  186. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  187. {Name: "NodeLabel", Weight: 8}, // Weight is 4 * number of LabelPreference priorities
  188. {Name: "DefaultPodTopologySpread", Weight: 2},
  189. {Name: "ServiceAffinity", Weight: 6}, // Weight is the 3 * number of custom ServiceAntiAffinity priorities
  190. },
  191. "BindPlugin": {{Name: "DefaultBinder"}},
  192. },
  193. },
  194. // Do not change this JSON after the corresponding release has been tagged.
  195. // A failure indicates backwards compatibility with the specified release was broken.
  196. {
  197. name: "1.2",
  198. JSON: `{
  199. "kind": "Policy",
  200. "apiVersion": "v1",
  201. "predicates": [
  202. {"name": "MatchNodeSelector"},
  203. {"name": "PodFitsResources"},
  204. {"name": "PodFitsHostPorts"},
  205. {"name": "HostName"},
  206. {"name": "NoDiskConflict"},
  207. {"name": "NoVolumeZoneConflict"},
  208. {"name": "MaxEBSVolumeCount"},
  209. {"name": "MaxGCEPDVolumeCount"},
  210. {"name": "MaxAzureDiskVolumeCount"},
  211. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  212. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  213. ],"priorities": [
  214. {"name": "EqualPriority", "weight": 2},
  215. {"name": "NodeAffinityPriority", "weight": 2},
  216. {"name": "ImageLocalityPriority", "weight": 2},
  217. {"name": "LeastRequestedPriority", "weight": 2},
  218. {"name": "BalancedResourceAllocation", "weight": 2},
  219. {"name": "SelectorSpreadPriority", "weight": 2},
  220. {"name": "TestServiceAntiAffinity", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  221. {"name": "TestLabelPreference", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}}
  222. ]
  223. }`,
  224. wantPlugins: map[string][]config.Plugin{
  225. "QueueSortPlugin": {{Name: "PrioritySort"}},
  226. "PreFilterPlugin": {
  227. {Name: "NodePorts"},
  228. {Name: "NodeResourcesFit"},
  229. {Name: "ServiceAffinity"},
  230. },
  231. "FilterPlugin": {
  232. {Name: "NodeUnschedulable"},
  233. {Name: "NodeName"},
  234. {Name: "NodePorts"},
  235. {Name: "NodeAffinity"},
  236. {Name: "NodeResourcesFit"},
  237. {Name: "VolumeRestrictions"},
  238. {Name: "TaintToleration"},
  239. {Name: "NodeLabel"},
  240. {Name: "ServiceAffinity"},
  241. {Name: "EBSLimits"},
  242. {Name: "GCEPDLimits"},
  243. {Name: "AzureDiskLimits"},
  244. {Name: "VolumeZone"},
  245. },
  246. "PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
  247. "ScorePlugin": {
  248. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  249. {Name: "ImageLocality", Weight: 2},
  250. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  251. {Name: "NodeAffinity", Weight: 2},
  252. {Name: "NodeLabel", Weight: 4},
  253. {Name: "DefaultPodTopologySpread", Weight: 2},
  254. {Name: "ServiceAffinity", Weight: 3},
  255. },
  256. "BindPlugin": {{Name: "DefaultBinder"}},
  257. },
  258. },
  259. // Do not change this JSON after the corresponding release has been tagged.
  260. // A failure indicates backwards compatibility with the specified release was broken.
  261. {
  262. name: "1.3",
  263. JSON: `{
  264. "kind": "Policy",
  265. "apiVersion": "v1",
  266. "predicates": [
  267. {"name": "MatchNodeSelector"},
  268. {"name": "PodFitsResources"},
  269. {"name": "PodFitsHostPorts"},
  270. {"name": "HostName"},
  271. {"name": "NoDiskConflict"},
  272. {"name": "NoVolumeZoneConflict"},
  273. {"name": "PodToleratesNodeTaints"},
  274. {"name": "MaxEBSVolumeCount"},
  275. {"name": "MaxGCEPDVolumeCount"},
  276. {"name": "MaxAzureDiskVolumeCount"},
  277. {"name": "MatchInterPodAffinity"},
  278. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  279. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  280. ],"priorities": [
  281. {"name": "EqualPriority", "weight": 2},
  282. {"name": "ImageLocalityPriority", "weight": 2},
  283. {"name": "LeastRequestedPriority", "weight": 2},
  284. {"name": "BalancedResourceAllocation", "weight": 2},
  285. {"name": "SelectorSpreadPriority", "weight": 2},
  286. {"name": "NodeAffinityPriority", "weight": 2},
  287. {"name": "TaintTolerationPriority", "weight": 2},
  288. {"name": "InterPodAffinityPriority", "weight": 2}
  289. ]
  290. }`,
  291. wantPlugins: map[string][]config.Plugin{
  292. "QueueSortPlugin": {{Name: "PrioritySort"}},
  293. "PreFilterPlugin": {
  294. {Name: "NodePorts"},
  295. {Name: "NodeResourcesFit"},
  296. {Name: "ServiceAffinity"},
  297. {Name: "InterPodAffinity"},
  298. },
  299. "FilterPlugin": {
  300. {Name: "NodeUnschedulable"},
  301. {Name: "NodeName"},
  302. {Name: "NodePorts"},
  303. {Name: "NodeAffinity"},
  304. {Name: "NodeResourcesFit"},
  305. {Name: "VolumeRestrictions"},
  306. {Name: "TaintToleration"},
  307. {Name: "NodeLabel"},
  308. {Name: "ServiceAffinity"},
  309. {Name: "EBSLimits"},
  310. {Name: "GCEPDLimits"},
  311. {Name: "AzureDiskLimits"},
  312. {Name: "VolumeZone"},
  313. {Name: "InterPodAffinity"},
  314. },
  315. "PreScorePlugin": {
  316. {Name: "InterPodAffinity"},
  317. {Name: "DefaultPodTopologySpread"},
  318. {Name: "TaintToleration"},
  319. },
  320. "ScorePlugin": {
  321. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  322. {Name: "ImageLocality", Weight: 2},
  323. {Name: "InterPodAffinity", Weight: 2},
  324. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  325. {Name: "NodeAffinity", Weight: 2},
  326. {Name: "DefaultPodTopologySpread", Weight: 2},
  327. {Name: "TaintToleration", Weight: 2},
  328. },
  329. "BindPlugin": {{Name: "DefaultBinder"}},
  330. },
  331. },
  332. // Do not change this JSON after the corresponding release has been tagged.
  333. // A failure indicates backwards compatibility with the specified release was broken.
  334. {
  335. name: "1.4",
  336. JSON: `{
  337. "kind": "Policy",
  338. "apiVersion": "v1",
  339. "predicates": [
  340. {"name": "MatchNodeSelector"},
  341. {"name": "PodFitsResources"},
  342. {"name": "PodFitsHostPorts"},
  343. {"name": "HostName"},
  344. {"name": "NoDiskConflict"},
  345. {"name": "NoVolumeZoneConflict"},
  346. {"name": "PodToleratesNodeTaints"},
  347. {"name": "MaxEBSVolumeCount"},
  348. {"name": "MaxGCEPDVolumeCount"},
  349. {"name": "MaxAzureDiskVolumeCount"},
  350. {"name": "MatchInterPodAffinity"},
  351. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  352. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  353. ],"priorities": [
  354. {"name": "EqualPriority", "weight": 2},
  355. {"name": "ImageLocalityPriority", "weight": 2},
  356. {"name": "LeastRequestedPriority", "weight": 2},
  357. {"name": "BalancedResourceAllocation", "weight": 2},
  358. {"name": "SelectorSpreadPriority", "weight": 2},
  359. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  360. {"name": "NodeAffinityPriority", "weight": 2},
  361. {"name": "TaintTolerationPriority", "weight": 2},
  362. {"name": "InterPodAffinityPriority", "weight": 2},
  363. {"name": "MostRequestedPriority", "weight": 2}
  364. ]
  365. }`,
  366. wantPlugins: map[string][]config.Plugin{
  367. "QueueSortPlugin": {{Name: "PrioritySort"}},
  368. "PreFilterPlugin": {
  369. {Name: "NodePorts"},
  370. {Name: "NodeResourcesFit"},
  371. {Name: "ServiceAffinity"},
  372. {Name: "InterPodAffinity"},
  373. },
  374. "FilterPlugin": {
  375. {Name: "NodeUnschedulable"},
  376. {Name: "NodeName"},
  377. {Name: "NodePorts"},
  378. {Name: "NodeAffinity"},
  379. {Name: "NodeResourcesFit"},
  380. {Name: "VolumeRestrictions"},
  381. {Name: "TaintToleration"},
  382. {Name: "NodeLabel"},
  383. {Name: "ServiceAffinity"},
  384. {Name: "EBSLimits"},
  385. {Name: "GCEPDLimits"},
  386. {Name: "AzureDiskLimits"},
  387. {Name: "VolumeZone"},
  388. {Name: "InterPodAffinity"},
  389. },
  390. "PreScorePlugin": {
  391. {Name: "InterPodAffinity"},
  392. {Name: "DefaultPodTopologySpread"},
  393. {Name: "TaintToleration"},
  394. },
  395. "ScorePlugin": {
  396. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  397. {Name: "ImageLocality", Weight: 2},
  398. {Name: "InterPodAffinity", Weight: 2},
  399. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  400. {Name: "NodeResourcesMostAllocated", Weight: 2},
  401. {Name: "NodeAffinity", Weight: 2},
  402. {Name: "NodePreferAvoidPods", Weight: 2},
  403. {Name: "DefaultPodTopologySpread", Weight: 2},
  404. {Name: "TaintToleration", Weight: 2},
  405. },
  406. "BindPlugin": {{Name: "DefaultBinder"}},
  407. },
  408. },
  409. // Do not change this JSON after the corresponding release has been tagged.
  410. // A failure indicates backwards compatibility with the specified release was broken.
  411. {
  412. name: "1.7",
  413. JSON: `{
  414. "kind": "Policy",
  415. "apiVersion": "v1",
  416. "predicates": [
  417. {"name": "MatchNodeSelector"},
  418. {"name": "PodFitsResources"},
  419. {"name": "PodFitsHostPorts"},
  420. {"name": "HostName"},
  421. {"name": "NoDiskConflict"},
  422. {"name": "NoVolumeZoneConflict"},
  423. {"name": "PodToleratesNodeTaints"},
  424. {"name": "MaxEBSVolumeCount"},
  425. {"name": "MaxGCEPDVolumeCount"},
  426. {"name": "MaxAzureDiskVolumeCount"},
  427. {"name": "MatchInterPodAffinity"},
  428. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  429. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  430. ],"priorities": [
  431. {"name": "EqualPriority", "weight": 2},
  432. {"name": "ImageLocalityPriority", "weight": 2},
  433. {"name": "LeastRequestedPriority", "weight": 2},
  434. {"name": "BalancedResourceAllocation", "weight": 2},
  435. {"name": "SelectorSpreadPriority", "weight": 2},
  436. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  437. {"name": "NodeAffinityPriority", "weight": 2},
  438. {"name": "TaintTolerationPriority", "weight": 2},
  439. {"name": "InterPodAffinityPriority", "weight": 2},
  440. {"name": "MostRequestedPriority", "weight": 2}
  441. ],"extenders": [{
  442. "urlPrefix": "/prefix",
  443. "filterVerb": "filter",
  444. "prioritizeVerb": "prioritize",
  445. "weight": 1,
  446. "BindVerb": "bind",
  447. "enableHttps": true,
  448. "tlsConfig": {"Insecure":true},
  449. "httpTimeout": 1,
  450. "nodeCacheCapable": true
  451. }]
  452. }`,
  453. wantPlugins: map[string][]config.Plugin{
  454. "QueueSortPlugin": {{Name: "PrioritySort"}},
  455. "PreFilterPlugin": {
  456. {Name: "NodePorts"},
  457. {Name: "NodeResourcesFit"},
  458. {Name: "ServiceAffinity"},
  459. {Name: "InterPodAffinity"},
  460. },
  461. "FilterPlugin": {
  462. {Name: "NodeUnschedulable"},
  463. {Name: "NodeName"},
  464. {Name: "NodePorts"},
  465. {Name: "NodeAffinity"},
  466. {Name: "NodeResourcesFit"},
  467. {Name: "VolumeRestrictions"},
  468. {Name: "TaintToleration"},
  469. {Name: "NodeLabel"},
  470. {Name: "ServiceAffinity"},
  471. {Name: "EBSLimits"},
  472. {Name: "GCEPDLimits"},
  473. {Name: "AzureDiskLimits"},
  474. {Name: "VolumeZone"},
  475. {Name: "InterPodAffinity"},
  476. },
  477. "PreScorePlugin": {
  478. {Name: "InterPodAffinity"},
  479. {Name: "DefaultPodTopologySpread"},
  480. {Name: "TaintToleration"},
  481. },
  482. "ScorePlugin": {
  483. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  484. {Name: "ImageLocality", Weight: 2},
  485. {Name: "InterPodAffinity", Weight: 2},
  486. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  487. {Name: "NodeResourcesMostAllocated", Weight: 2},
  488. {Name: "NodeAffinity", Weight: 2},
  489. {Name: "NodePreferAvoidPods", Weight: 2},
  490. {Name: "DefaultPodTopologySpread", Weight: 2},
  491. {Name: "TaintToleration", Weight: 2},
  492. },
  493. "BindPlugin": {{Name: "DefaultBinder"}},
  494. },
  495. wantExtenders: []config.Extender{{
  496. URLPrefix: "/prefix",
  497. FilterVerb: "filter",
  498. PrioritizeVerb: "prioritize",
  499. Weight: 1,
  500. BindVerb: "bind", // 1.7 was missing json tags on the BindVerb field and required "BindVerb"
  501. EnableHTTPS: true,
  502. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  503. HTTPTimeout: 1,
  504. NodeCacheCapable: true,
  505. }},
  506. },
  507. // Do not change this JSON after the corresponding release has been tagged.
  508. // A failure indicates backwards compatibility with the specified release was broken.
  509. {
  510. name: "1.8",
  511. JSON: `{
  512. "kind": "Policy",
  513. "apiVersion": "v1",
  514. "predicates": [
  515. {"name": "MatchNodeSelector"},
  516. {"name": "PodFitsResources"},
  517. {"name": "PodFitsHostPorts"},
  518. {"name": "HostName"},
  519. {"name": "NoDiskConflict"},
  520. {"name": "NoVolumeZoneConflict"},
  521. {"name": "PodToleratesNodeTaints"},
  522. {"name": "MaxEBSVolumeCount"},
  523. {"name": "MaxGCEPDVolumeCount"},
  524. {"name": "MaxAzureDiskVolumeCount"},
  525. {"name": "MatchInterPodAffinity"},
  526. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  527. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  528. ],"priorities": [
  529. {"name": "EqualPriority", "weight": 2},
  530. {"name": "ImageLocalityPriority", "weight": 2},
  531. {"name": "LeastRequestedPriority", "weight": 2},
  532. {"name": "BalancedResourceAllocation", "weight": 2},
  533. {"name": "SelectorSpreadPriority", "weight": 2},
  534. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  535. {"name": "NodeAffinityPriority", "weight": 2},
  536. {"name": "TaintTolerationPriority", "weight": 2},
  537. {"name": "InterPodAffinityPriority", "weight": 2},
  538. {"name": "MostRequestedPriority", "weight": 2}
  539. ],"extenders": [{
  540. "urlPrefix": "/prefix",
  541. "filterVerb": "filter",
  542. "prioritizeVerb": "prioritize",
  543. "weight": 1,
  544. "bindVerb": "bind",
  545. "enableHttps": true,
  546. "tlsConfig": {"Insecure":true},
  547. "httpTimeout": 1,
  548. "nodeCacheCapable": true
  549. }]
  550. }`,
  551. wantPlugins: map[string][]config.Plugin{
  552. "QueueSortPlugin": {{Name: "PrioritySort"}},
  553. "PreFilterPlugin": {
  554. {Name: "NodePorts"},
  555. {Name: "NodeResourcesFit"},
  556. {Name: "ServiceAffinity"},
  557. {Name: "InterPodAffinity"},
  558. },
  559. "FilterPlugin": {
  560. {Name: "NodeUnschedulable"},
  561. {Name: "NodeName"},
  562. {Name: "NodePorts"},
  563. {Name: "NodeAffinity"},
  564. {Name: "NodeResourcesFit"},
  565. {Name: "VolumeRestrictions"},
  566. {Name: "TaintToleration"},
  567. {Name: "NodeLabel"},
  568. {Name: "ServiceAffinity"},
  569. {Name: "EBSLimits"},
  570. {Name: "GCEPDLimits"},
  571. {Name: "AzureDiskLimits"},
  572. {Name: "VolumeZone"},
  573. {Name: "InterPodAffinity"},
  574. },
  575. "PreScorePlugin": {
  576. {Name: "InterPodAffinity"},
  577. {Name: "DefaultPodTopologySpread"},
  578. {Name: "TaintToleration"},
  579. },
  580. "ScorePlugin": {
  581. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  582. {Name: "ImageLocality", Weight: 2},
  583. {Name: "InterPodAffinity", Weight: 2},
  584. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  585. {Name: "NodeResourcesMostAllocated", Weight: 2},
  586. {Name: "NodeAffinity", Weight: 2},
  587. {Name: "NodePreferAvoidPods", Weight: 2},
  588. {Name: "DefaultPodTopologySpread", Weight: 2},
  589. {Name: "TaintToleration", Weight: 2},
  590. },
  591. "BindPlugin": {{Name: "DefaultBinder"}},
  592. },
  593. wantExtenders: []config.Extender{{
  594. URLPrefix: "/prefix",
  595. FilterVerb: "filter",
  596. PrioritizeVerb: "prioritize",
  597. Weight: 1,
  598. BindVerb: "bind", // 1.8 became case-insensitive and tolerated "bindVerb"
  599. EnableHTTPS: true,
  600. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  601. HTTPTimeout: 1,
  602. NodeCacheCapable: true,
  603. }},
  604. },
  605. // Do not change this JSON after the corresponding release has been tagged.
  606. // A failure indicates backwards compatibility with the specified release was broken.
  607. {
  608. name: "1.9",
  609. JSON: `{
  610. "kind": "Policy",
  611. "apiVersion": "v1",
  612. "predicates": [
  613. {"name": "MatchNodeSelector"},
  614. {"name": "PodFitsResources"},
  615. {"name": "PodFitsHostPorts"},
  616. {"name": "HostName"},
  617. {"name": "NoDiskConflict"},
  618. {"name": "NoVolumeZoneConflict"},
  619. {"name": "PodToleratesNodeTaints"},
  620. {"name": "MaxEBSVolumeCount"},
  621. {"name": "MaxGCEPDVolumeCount"},
  622. {"name": "MaxAzureDiskVolumeCount"},
  623. {"name": "MatchInterPodAffinity"},
  624. {"name": "CheckVolumeBinding"},
  625. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  626. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  627. ],"priorities": [
  628. {"name": "EqualPriority", "weight": 2},
  629. {"name": "ImageLocalityPriority", "weight": 2},
  630. {"name": "LeastRequestedPriority", "weight": 2},
  631. {"name": "BalancedResourceAllocation", "weight": 2},
  632. {"name": "SelectorSpreadPriority", "weight": 2},
  633. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  634. {"name": "NodeAffinityPriority", "weight": 2},
  635. {"name": "TaintTolerationPriority", "weight": 2},
  636. {"name": "InterPodAffinityPriority", "weight": 2},
  637. {"name": "MostRequestedPriority", "weight": 2}
  638. ],"extenders": [{
  639. "urlPrefix": "/prefix",
  640. "filterVerb": "filter",
  641. "prioritizeVerb": "prioritize",
  642. "weight": 1,
  643. "bindVerb": "bind",
  644. "enableHttps": true,
  645. "tlsConfig": {"Insecure":true},
  646. "httpTimeout": 1,
  647. "nodeCacheCapable": true
  648. }]
  649. }`,
  650. wantPlugins: map[string][]config.Plugin{
  651. "QueueSortPlugin": {{Name: "PrioritySort"}},
  652. "PreFilterPlugin": {
  653. {Name: "NodePorts"},
  654. {Name: "NodeResourcesFit"},
  655. {Name: "ServiceAffinity"},
  656. {Name: "InterPodAffinity"},
  657. },
  658. "FilterPlugin": {
  659. {Name: "NodeUnschedulable"},
  660. {Name: "NodeName"},
  661. {Name: "NodePorts"},
  662. {Name: "NodeAffinity"},
  663. {Name: "NodeResourcesFit"},
  664. {Name: "VolumeRestrictions"},
  665. {Name: "TaintToleration"},
  666. {Name: "NodeLabel"},
  667. {Name: "ServiceAffinity"},
  668. {Name: "EBSLimits"},
  669. {Name: "GCEPDLimits"},
  670. {Name: "AzureDiskLimits"},
  671. {Name: "VolumeBinding"},
  672. {Name: "VolumeZone"},
  673. {Name: "InterPodAffinity"},
  674. },
  675. "PreScorePlugin": {
  676. {Name: "InterPodAffinity"},
  677. {Name: "DefaultPodTopologySpread"},
  678. {Name: "TaintToleration"},
  679. },
  680. "ScorePlugin": {
  681. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  682. {Name: "ImageLocality", Weight: 2},
  683. {Name: "InterPodAffinity", Weight: 2},
  684. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  685. {Name: "NodeResourcesMostAllocated", Weight: 2},
  686. {Name: "NodeAffinity", Weight: 2},
  687. {Name: "NodePreferAvoidPods", Weight: 2},
  688. {Name: "DefaultPodTopologySpread", Weight: 2},
  689. {Name: "TaintToleration", Weight: 2},
  690. },
  691. "BindPlugin": {{Name: "DefaultBinder"}},
  692. },
  693. wantExtenders: []config.Extender{{
  694. URLPrefix: "/prefix",
  695. FilterVerb: "filter",
  696. PrioritizeVerb: "prioritize",
  697. Weight: 1,
  698. BindVerb: "bind", // 1.9 was case-insensitive and tolerated "bindVerb"
  699. EnableHTTPS: true,
  700. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  701. HTTPTimeout: 1,
  702. NodeCacheCapable: true,
  703. }},
  704. },
  705. // Do not change this JSON after the corresponding release has been tagged.
  706. // A failure indicates backwards compatibility with the specified release was broken.
  707. {
  708. name: "1.10",
  709. JSON: `{
  710. "kind": "Policy",
  711. "apiVersion": "v1",
  712. "predicates": [
  713. {"name": "MatchNodeSelector"},
  714. {"name": "PodFitsResources"},
  715. {"name": "PodFitsHostPorts"},
  716. {"name": "HostName"},
  717. {"name": "NoDiskConflict"},
  718. {"name": "NoVolumeZoneConflict"},
  719. {"name": "PodToleratesNodeTaints"},
  720. {"name": "MaxEBSVolumeCount"},
  721. {"name": "MaxGCEPDVolumeCount"},
  722. {"name": "MaxAzureDiskVolumeCount"},
  723. {"name": "MatchInterPodAffinity"},
  724. {"name": "CheckVolumeBinding"},
  725. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  726. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  727. ],"priorities": [
  728. {"name": "EqualPriority", "weight": 2},
  729. {"name": "ImageLocalityPriority", "weight": 2},
  730. {"name": "LeastRequestedPriority", "weight": 2},
  731. {"name": "BalancedResourceAllocation", "weight": 2},
  732. {"name": "SelectorSpreadPriority", "weight": 2},
  733. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  734. {"name": "NodeAffinityPriority", "weight": 2},
  735. {"name": "TaintTolerationPriority", "weight": 2},
  736. {"name": "InterPodAffinityPriority", "weight": 2},
  737. {"name": "MostRequestedPriority", "weight": 2}
  738. ],"extenders": [{
  739. "urlPrefix": "/prefix",
  740. "filterVerb": "filter",
  741. "prioritizeVerb": "prioritize",
  742. "weight": 1,
  743. "bindVerb": "bind",
  744. "enableHttps": true,
  745. "tlsConfig": {"Insecure":true},
  746. "httpTimeout": 1,
  747. "nodeCacheCapable": true,
  748. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  749. "ignorable":true
  750. }]
  751. }`,
  752. wantPlugins: map[string][]config.Plugin{
  753. "QueueSortPlugin": {{Name: "PrioritySort"}},
  754. "PreFilterPlugin": {
  755. {Name: "NodePorts"},
  756. {Name: "NodeResourcesFit"},
  757. {Name: "ServiceAffinity"},
  758. {Name: "InterPodAffinity"},
  759. },
  760. "FilterPlugin": {
  761. {Name: "NodeUnschedulable"},
  762. {Name: "NodeName"},
  763. {Name: "NodePorts"},
  764. {Name: "NodeAffinity"},
  765. {Name: "NodeResourcesFit"},
  766. {Name: "VolumeRestrictions"},
  767. {Name: "TaintToleration"},
  768. {Name: "NodeLabel"},
  769. {Name: "ServiceAffinity"},
  770. {Name: "EBSLimits"},
  771. {Name: "GCEPDLimits"},
  772. {Name: "AzureDiskLimits"},
  773. {Name: "VolumeBinding"},
  774. {Name: "VolumeZone"},
  775. {Name: "InterPodAffinity"},
  776. },
  777. "PreScorePlugin": {
  778. {Name: "InterPodAffinity"},
  779. {Name: "DefaultPodTopologySpread"},
  780. {Name: "TaintToleration"},
  781. },
  782. "ScorePlugin": {
  783. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  784. {Name: "ImageLocality", Weight: 2},
  785. {Name: "InterPodAffinity", Weight: 2},
  786. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  787. {Name: "NodeResourcesMostAllocated", Weight: 2},
  788. {Name: "NodeAffinity", Weight: 2},
  789. {Name: "NodePreferAvoidPods", Weight: 2},
  790. {Name: "DefaultPodTopologySpread", Weight: 2},
  791. {Name: "TaintToleration", Weight: 2},
  792. },
  793. "BindPlugin": {{Name: "DefaultBinder"}},
  794. },
  795. wantExtenders: []config.Extender{{
  796. URLPrefix: "/prefix",
  797. FilterVerb: "filter",
  798. PrioritizeVerb: "prioritize",
  799. Weight: 1,
  800. BindVerb: "bind", // 1.10 was case-insensitive and tolerated "bindVerb"
  801. EnableHTTPS: true,
  802. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  803. HTTPTimeout: 1,
  804. NodeCacheCapable: true,
  805. ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
  806. Ignorable: true,
  807. }},
  808. },
  809. // Do not change this JSON after the corresponding release has been tagged.
  810. // A failure indicates backwards compatibility with the specified release was broken.
  811. {
  812. name: "1.11",
  813. JSON: `{
  814. "kind": "Policy",
  815. "apiVersion": "v1",
  816. "predicates": [
  817. {"name": "MatchNodeSelector"},
  818. {"name": "PodFitsResources"},
  819. {"name": "PodFitsHostPorts"},
  820. {"name": "HostName"},
  821. {"name": "NoDiskConflict"},
  822. {"name": "NoVolumeZoneConflict"},
  823. {"name": "PodToleratesNodeTaints"},
  824. {"name": "MaxEBSVolumeCount"},
  825. {"name": "MaxGCEPDVolumeCount"},
  826. {"name": "MaxAzureDiskVolumeCount"},
  827. {"name": "MatchInterPodAffinity"},
  828. {"name": "CheckVolumeBinding"},
  829. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  830. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  831. ],"priorities": [
  832. {"name": "EqualPriority", "weight": 2},
  833. {"name": "ImageLocalityPriority", "weight": 2},
  834. {"name": "LeastRequestedPriority", "weight": 2},
  835. {"name": "BalancedResourceAllocation", "weight": 2},
  836. {"name": "SelectorSpreadPriority", "weight": 2},
  837. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  838. {"name": "NodeAffinityPriority", "weight": 2},
  839. {"name": "TaintTolerationPriority", "weight": 2},
  840. {"name": "InterPodAffinityPriority", "weight": 2},
  841. {"name": "MostRequestedPriority", "weight": 2},
  842. {
  843. "name": "RequestedToCapacityRatioPriority",
  844. "weight": 2,
  845. "argument": {
  846. "requestedToCapacityRatioArguments": {
  847. "shape": [
  848. {"utilization": 0, "score": 0},
  849. {"utilization": 50, "score": 7}
  850. ]
  851. }
  852. }}
  853. ],"extenders": [{
  854. "urlPrefix": "/prefix",
  855. "filterVerb": "filter",
  856. "prioritizeVerb": "prioritize",
  857. "weight": 1,
  858. "bindVerb": "bind",
  859. "enableHttps": true,
  860. "tlsConfig": {"Insecure":true},
  861. "httpTimeout": 1,
  862. "nodeCacheCapable": true,
  863. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  864. "ignorable":true
  865. }]
  866. }`,
  867. wantPlugins: map[string][]config.Plugin{
  868. "QueueSortPlugin": {{Name: "PrioritySort"}},
  869. "PreFilterPlugin": {
  870. {Name: "NodePorts"},
  871. {Name: "NodeResourcesFit"},
  872. {Name: "ServiceAffinity"},
  873. {Name: "InterPodAffinity"},
  874. },
  875. "FilterPlugin": {
  876. {Name: "NodeUnschedulable"},
  877. {Name: "NodeName"},
  878. {Name: "NodePorts"},
  879. {Name: "NodeAffinity"},
  880. {Name: "NodeResourcesFit"},
  881. {Name: "VolumeRestrictions"},
  882. {Name: "TaintToleration"},
  883. {Name: "NodeLabel"},
  884. {Name: "ServiceAffinity"},
  885. {Name: "EBSLimits"},
  886. {Name: "GCEPDLimits"},
  887. {Name: "AzureDiskLimits"},
  888. {Name: "VolumeBinding"},
  889. {Name: "VolumeZone"},
  890. {Name: "InterPodAffinity"},
  891. },
  892. "PreScorePlugin": {
  893. {Name: "InterPodAffinity"},
  894. {Name: "DefaultPodTopologySpread"},
  895. {Name: "TaintToleration"},
  896. },
  897. "ScorePlugin": {
  898. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  899. {Name: "ImageLocality", Weight: 2},
  900. {Name: "InterPodAffinity", Weight: 2},
  901. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  902. {Name: "NodeResourcesMostAllocated", Weight: 2},
  903. {Name: "NodeAffinity", Weight: 2},
  904. {Name: "NodePreferAvoidPods", Weight: 2},
  905. {Name: "RequestedToCapacityRatio", Weight: 2},
  906. {Name: "DefaultPodTopologySpread", Weight: 2},
  907. {Name: "TaintToleration", Weight: 2},
  908. },
  909. "BindPlugin": {{Name: "DefaultBinder"}},
  910. },
  911. wantExtenders: []config.Extender{{
  912. URLPrefix: "/prefix",
  913. FilterVerb: "filter",
  914. PrioritizeVerb: "prioritize",
  915. Weight: 1,
  916. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  917. EnableHTTPS: true,
  918. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  919. HTTPTimeout: 1,
  920. NodeCacheCapable: true,
  921. ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
  922. Ignorable: true,
  923. }},
  924. },
  925. // Do not change this JSON after the corresponding release has been tagged.
  926. // A failure indicates backwards compatibility with the specified release was broken.
  927. {
  928. name: "1.12",
  929. JSON: `{
  930. "kind": "Policy",
  931. "apiVersion": "v1",
  932. "predicates": [
  933. {"name": "MatchNodeSelector"},
  934. {"name": "PodFitsResources"},
  935. {"name": "PodFitsHostPorts"},
  936. {"name": "HostName"},
  937. {"name": "NoDiskConflict"},
  938. {"name": "NoVolumeZoneConflict"},
  939. {"name": "PodToleratesNodeTaints"},
  940. {"name": "MaxEBSVolumeCount"},
  941. {"name": "MaxGCEPDVolumeCount"},
  942. {"name": "MaxAzureDiskVolumeCount"},
  943. {"name": "MaxCSIVolumeCountPred"},
  944. {"name": "MatchInterPodAffinity"},
  945. {"name": "CheckVolumeBinding"},
  946. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  947. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  948. ],"priorities": [
  949. {"name": "EqualPriority", "weight": 2},
  950. {"name": "ImageLocalityPriority", "weight": 2},
  951. {"name": "LeastRequestedPriority", "weight": 2},
  952. {"name": "BalancedResourceAllocation", "weight": 2},
  953. {"name": "SelectorSpreadPriority", "weight": 2},
  954. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  955. {"name": "NodeAffinityPriority", "weight": 2},
  956. {"name": "TaintTolerationPriority", "weight": 2},
  957. {"name": "InterPodAffinityPriority", "weight": 2},
  958. {"name": "MostRequestedPriority", "weight": 2},
  959. {
  960. "name": "RequestedToCapacityRatioPriority",
  961. "weight": 2,
  962. "argument": {
  963. "requestedToCapacityRatioArguments": {
  964. "shape": [
  965. {"utilization": 0, "score": 0},
  966. {"utilization": 50, "score": 7}
  967. ]
  968. }
  969. }}
  970. ],"extenders": [{
  971. "urlPrefix": "/prefix",
  972. "filterVerb": "filter",
  973. "prioritizeVerb": "prioritize",
  974. "weight": 1,
  975. "bindVerb": "bind",
  976. "enableHttps": true,
  977. "tlsConfig": {"Insecure":true},
  978. "httpTimeout": 1,
  979. "nodeCacheCapable": true,
  980. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  981. "ignorable":true
  982. }]
  983. }`,
  984. wantPlugins: map[string][]config.Plugin{
  985. "QueueSortPlugin": {{Name: "PrioritySort"}},
  986. "PreFilterPlugin": {
  987. {Name: "NodePorts"},
  988. {Name: "NodeResourcesFit"},
  989. {Name: "ServiceAffinity"},
  990. {Name: "InterPodAffinity"},
  991. },
  992. "FilterPlugin": {
  993. {Name: "NodeUnschedulable"},
  994. {Name: "NodeName"},
  995. {Name: "NodePorts"},
  996. {Name: "NodeAffinity"},
  997. {Name: "NodeResourcesFit"},
  998. {Name: "VolumeRestrictions"},
  999. {Name: "TaintToleration"},
  1000. {Name: "NodeLabel"},
  1001. {Name: "ServiceAffinity"},
  1002. {Name: "EBSLimits"},
  1003. {Name: "GCEPDLimits"},
  1004. {Name: "NodeVolumeLimits"},
  1005. {Name: "AzureDiskLimits"},
  1006. {Name: "VolumeBinding"},
  1007. {Name: "VolumeZone"},
  1008. {Name: "InterPodAffinity"},
  1009. },
  1010. "PreScorePlugin": {
  1011. {Name: "InterPodAffinity"},
  1012. {Name: "DefaultPodTopologySpread"},
  1013. {Name: "TaintToleration"},
  1014. },
  1015. "ScorePlugin": {
  1016. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  1017. {Name: "ImageLocality", Weight: 2},
  1018. {Name: "InterPodAffinity", Weight: 2},
  1019. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  1020. {Name: "NodeResourcesMostAllocated", Weight: 2},
  1021. {Name: "NodeAffinity", Weight: 2},
  1022. {Name: "NodePreferAvoidPods", Weight: 2},
  1023. {Name: "RequestedToCapacityRatio", Weight: 2},
  1024. {Name: "DefaultPodTopologySpread", Weight: 2},
  1025. {Name: "TaintToleration", Weight: 2},
  1026. },
  1027. "BindPlugin": {{Name: "DefaultBinder"}},
  1028. },
  1029. wantExtenders: []config.Extender{{
  1030. URLPrefix: "/prefix",
  1031. FilterVerb: "filter",
  1032. PrioritizeVerb: "prioritize",
  1033. Weight: 1,
  1034. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  1035. EnableHTTPS: true,
  1036. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  1037. HTTPTimeout: 1,
  1038. NodeCacheCapable: true,
  1039. ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
  1040. Ignorable: true,
  1041. }},
  1042. },
  1043. {
  1044. name: "1.14",
  1045. JSON: `{
  1046. "kind": "Policy",
  1047. "apiVersion": "v1",
  1048. "predicates": [
  1049. {"name": "MatchNodeSelector"},
  1050. {"name": "PodFitsResources"},
  1051. {"name": "PodFitsHostPorts"},
  1052. {"name": "HostName"},
  1053. {"name": "NoDiskConflict"},
  1054. {"name": "NoVolumeZoneConflict"},
  1055. {"name": "PodToleratesNodeTaints"},
  1056. {"name": "MaxEBSVolumeCount"},
  1057. {"name": "MaxGCEPDVolumeCount"},
  1058. {"name": "MaxAzureDiskVolumeCount"},
  1059. {"name": "MaxCSIVolumeCountPred"},
  1060. {"name": "MaxCinderVolumeCount"},
  1061. {"name": "MatchInterPodAffinity"},
  1062. {"name": "CheckVolumeBinding"},
  1063. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  1064. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  1065. ],"priorities": [
  1066. {"name": "EqualPriority", "weight": 2},
  1067. {"name": "ImageLocalityPriority", "weight": 2},
  1068. {"name": "LeastRequestedPriority", "weight": 2},
  1069. {"name": "BalancedResourceAllocation", "weight": 2},
  1070. {"name": "SelectorSpreadPriority", "weight": 2},
  1071. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  1072. {"name": "NodeAffinityPriority", "weight": 2},
  1073. {"name": "TaintTolerationPriority", "weight": 2},
  1074. {"name": "InterPodAffinityPriority", "weight": 2},
  1075. {"name": "MostRequestedPriority", "weight": 2},
  1076. {
  1077. "name": "RequestedToCapacityRatioPriority",
  1078. "weight": 2,
  1079. "argument": {
  1080. "requestedToCapacityRatioArguments": {
  1081. "shape": [
  1082. {"utilization": 0, "score": 0},
  1083. {"utilization": 50, "score": 7}
  1084. ]
  1085. }
  1086. }}
  1087. ],"extenders": [{
  1088. "urlPrefix": "/prefix",
  1089. "filterVerb": "filter",
  1090. "prioritizeVerb": "prioritize",
  1091. "weight": 1,
  1092. "bindVerb": "bind",
  1093. "enableHttps": true,
  1094. "tlsConfig": {"Insecure":true},
  1095. "httpTimeout": 1,
  1096. "nodeCacheCapable": true,
  1097. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  1098. "ignorable":true
  1099. }]
  1100. }`,
  1101. wantPlugins: map[string][]config.Plugin{
  1102. "QueueSortPlugin": {{Name: "PrioritySort"}},
  1103. "PreFilterPlugin": {
  1104. {Name: "NodePorts"},
  1105. {Name: "NodeResourcesFit"},
  1106. {Name: "ServiceAffinity"},
  1107. {Name: "InterPodAffinity"},
  1108. },
  1109. "FilterPlugin": {
  1110. {Name: "NodeUnschedulable"},
  1111. {Name: "NodeName"},
  1112. {Name: "NodePorts"},
  1113. {Name: "NodeAffinity"},
  1114. {Name: "NodeResourcesFit"},
  1115. {Name: "VolumeRestrictions"},
  1116. {Name: "TaintToleration"},
  1117. {Name: "NodeLabel"},
  1118. {Name: "ServiceAffinity"},
  1119. {Name: "EBSLimits"},
  1120. {Name: "GCEPDLimits"},
  1121. {Name: "NodeVolumeLimits"},
  1122. {Name: "AzureDiskLimits"},
  1123. {Name: "CinderLimits"},
  1124. {Name: "VolumeBinding"},
  1125. {Name: "VolumeZone"},
  1126. {Name: "InterPodAffinity"},
  1127. },
  1128. "PreScorePlugin": {
  1129. {Name: "InterPodAffinity"},
  1130. {Name: "DefaultPodTopologySpread"},
  1131. {Name: "TaintToleration"},
  1132. },
  1133. "ScorePlugin": {
  1134. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  1135. {Name: "ImageLocality", Weight: 2},
  1136. {Name: "InterPodAffinity", Weight: 2},
  1137. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  1138. {Name: "NodeResourcesMostAllocated", Weight: 2},
  1139. {Name: "NodeAffinity", Weight: 2},
  1140. {Name: "NodePreferAvoidPods", Weight: 2},
  1141. {Name: "RequestedToCapacityRatio", Weight: 2},
  1142. {Name: "DefaultPodTopologySpread", Weight: 2},
  1143. {Name: "TaintToleration", Weight: 2},
  1144. },
  1145. "BindPlugin": {{Name: "DefaultBinder"}},
  1146. },
  1147. wantExtenders: []config.Extender{{
  1148. URLPrefix: "/prefix",
  1149. FilterVerb: "filter",
  1150. PrioritizeVerb: "prioritize",
  1151. Weight: 1,
  1152. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  1153. EnableHTTPS: true,
  1154. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  1155. HTTPTimeout: 1,
  1156. NodeCacheCapable: true,
  1157. ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
  1158. Ignorable: true,
  1159. }},
  1160. },
  1161. {
  1162. name: "1.16",
  1163. JSON: `{
  1164. "kind": "Policy",
  1165. "apiVersion": "v1",
  1166. "predicates": [
  1167. {"name": "MatchNodeSelector"},
  1168. {"name": "PodFitsResources"},
  1169. {"name": "PodFitsHostPorts"},
  1170. {"name": "HostName"},
  1171. {"name": "NoDiskConflict"},
  1172. {"name": "NoVolumeZoneConflict"},
  1173. {"name": "PodToleratesNodeTaints"},
  1174. {"name": "MaxEBSVolumeCount"},
  1175. {"name": "MaxGCEPDVolumeCount"},
  1176. {"name": "MaxAzureDiskVolumeCount"},
  1177. {"name": "MaxCSIVolumeCountPred"},
  1178. {"name": "MaxCinderVolumeCount"},
  1179. {"name": "MatchInterPodAffinity"},
  1180. {"name": "CheckVolumeBinding"},
  1181. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  1182. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  1183. ],"priorities": [
  1184. {"name": "EqualPriority", "weight": 2},
  1185. {"name": "ImageLocalityPriority", "weight": 2},
  1186. {"name": "LeastRequestedPriority", "weight": 2},
  1187. {"name": "BalancedResourceAllocation", "weight": 2},
  1188. {"name": "SelectorSpreadPriority", "weight": 2},
  1189. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  1190. {"name": "NodeAffinityPriority", "weight": 2},
  1191. {"name": "TaintTolerationPriority", "weight": 2},
  1192. {"name": "InterPodAffinityPriority", "weight": 2},
  1193. {"name": "MostRequestedPriority", "weight": 2},
  1194. {
  1195. "name": "RequestedToCapacityRatioPriority",
  1196. "weight": 2,
  1197. "argument": {
  1198. "requestedToCapacityRatioArguments": {
  1199. "shape": [
  1200. {"utilization": 0, "score": 0},
  1201. {"utilization": 50, "score": 7}
  1202. ],
  1203. "resources": [
  1204. {"name": "intel.com/foo", "weight": 3},
  1205. {"name": "intel.com/bar", "weight": 5}
  1206. ]
  1207. }
  1208. }}
  1209. ],"extenders": [{
  1210. "urlPrefix": "/prefix",
  1211. "filterVerb": "filter",
  1212. "prioritizeVerb": "prioritize",
  1213. "weight": 1,
  1214. "bindVerb": "bind",
  1215. "enableHttps": true,
  1216. "tlsConfig": {"Insecure":true},
  1217. "httpTimeout": 1,
  1218. "nodeCacheCapable": true,
  1219. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  1220. "ignorable":true
  1221. }]
  1222. }`,
  1223. wantPlugins: map[string][]config.Plugin{
  1224. "QueueSortPlugin": {{Name: "PrioritySort"}},
  1225. "PreFilterPlugin": {
  1226. {Name: "NodePorts"},
  1227. {Name: "NodeResourcesFit"},
  1228. {Name: "ServiceAffinity"},
  1229. {Name: "InterPodAffinity"},
  1230. },
  1231. "FilterPlugin": {
  1232. {Name: "NodeUnschedulable"},
  1233. {Name: "NodeName"},
  1234. {Name: "NodePorts"},
  1235. {Name: "NodeAffinity"},
  1236. {Name: "NodeResourcesFit"},
  1237. {Name: "VolumeRestrictions"},
  1238. {Name: "TaintToleration"},
  1239. {Name: "NodeLabel"},
  1240. {Name: "ServiceAffinity"},
  1241. {Name: "EBSLimits"},
  1242. {Name: "GCEPDLimits"},
  1243. {Name: "NodeVolumeLimits"},
  1244. {Name: "AzureDiskLimits"},
  1245. {Name: "CinderLimits"},
  1246. {Name: "VolumeBinding"},
  1247. {Name: "VolumeZone"},
  1248. {Name: "InterPodAffinity"},
  1249. },
  1250. "PreScorePlugin": {
  1251. {Name: "InterPodAffinity"},
  1252. {Name: "DefaultPodTopologySpread"},
  1253. {Name: "TaintToleration"},
  1254. },
  1255. "ScorePlugin": {
  1256. {Name: "NodeResourcesBalancedAllocation", Weight: 2},
  1257. {Name: "ImageLocality", Weight: 2},
  1258. {Name: "InterPodAffinity", Weight: 2},
  1259. {Name: "NodeResourcesLeastAllocated", Weight: 2},
  1260. {Name: "NodeResourcesMostAllocated", Weight: 2},
  1261. {Name: "NodeAffinity", Weight: 2},
  1262. {Name: "NodePreferAvoidPods", Weight: 2},
  1263. {Name: "RequestedToCapacityRatio", Weight: 2},
  1264. {Name: "DefaultPodTopologySpread", Weight: 2},
  1265. {Name: "TaintToleration", Weight: 2},
  1266. },
  1267. "BindPlugin": {{Name: "DefaultBinder"}},
  1268. },
  1269. wantExtenders: []config.Extender{{
  1270. URLPrefix: "/prefix",
  1271. FilterVerb: "filter",
  1272. PrioritizeVerb: "prioritize",
  1273. Weight: 1,
  1274. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  1275. EnableHTTPS: true,
  1276. TLSConfig: &config.ExtenderTLSConfig{Insecure: true},
  1277. HTTPTimeout: 1,
  1278. NodeCacheCapable: true,
  1279. ManagedResources: []config.ExtenderManagedResource{{Name: "example.com/foo", IgnoredByScheduler: true}},
  1280. Ignorable: true,
  1281. }},
  1282. },
  1283. {
  1284. name: "enable alpha feature EvenPodsSpread",
  1285. JSON: `{
  1286. "kind": "Policy",
  1287. "apiVersion": "v1",
  1288. "predicates": [
  1289. {"name": "EvenPodsSpread"}
  1290. ],
  1291. "priorities": [
  1292. {"name": "EvenPodsSpreadPriority", "weight": 2}
  1293. ]
  1294. }`,
  1295. featureGates: map[featuregate.Feature]bool{
  1296. features.EvenPodsSpread: true,
  1297. },
  1298. wantPlugins: map[string][]config.Plugin{
  1299. "QueueSortPlugin": {{Name: "PrioritySort"}},
  1300. "PreFilterPlugin": {
  1301. {Name: "PodTopologySpread"},
  1302. },
  1303. "FilterPlugin": {
  1304. {Name: "NodeUnschedulable"},
  1305. {Name: "TaintToleration"},
  1306. {Name: "PodTopologySpread"},
  1307. },
  1308. "PreScorePlugin": {
  1309. {Name: "PodTopologySpread"},
  1310. },
  1311. "ScorePlugin": {
  1312. {Name: "PodTopologySpread", Weight: 2},
  1313. },
  1314. "BindPlugin": {{Name: "DefaultBinder"}},
  1315. },
  1316. },
  1317. {
  1318. name: "enable alpha feature ResourceLimitsPriorityFunction",
  1319. JSON: `{
  1320. "kind": "Policy",
  1321. "apiVersion": "v1",
  1322. "predicates": [],
  1323. "priorities": [
  1324. {"name": "ResourceLimitsPriority", "weight": 2}
  1325. ]
  1326. }`,
  1327. featureGates: map[featuregate.Feature]bool{
  1328. features.ResourceLimitsPriorityFunction: true,
  1329. },
  1330. wantPlugins: map[string][]config.Plugin{
  1331. "QueueSortPlugin": {{Name: "PrioritySort"}},
  1332. "PreScorePlugin": {
  1333. {Name: "NodeResourceLimits"},
  1334. },
  1335. "FilterPlugin": {
  1336. {Name: "NodeUnschedulable"},
  1337. {Name: "TaintToleration"},
  1338. },
  1339. "ScorePlugin": {
  1340. {Name: "NodeResourceLimits", Weight: 2},
  1341. },
  1342. "BindPlugin": {{Name: "DefaultBinder"}},
  1343. },
  1344. },
  1345. }
  1346. for _, tc := range testcases {
  1347. t.Run(tc.name, func(t *testing.T) {
  1348. for feature, value := range tc.featureGates {
  1349. defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, feature, value)()
  1350. }
  1351. policyConfigMap := v1.ConfigMap{
  1352. ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceSystem, Name: "scheduler-custom-policy-config"},
  1353. Data: map[string]string{config.SchedulerPolicyConfigMapKey: tc.JSON},
  1354. }
  1355. client := fake.NewSimpleClientset(&policyConfigMap)
  1356. algorithmSrc := config.SchedulerAlgorithmSource{
  1357. Policy: &config.SchedulerPolicySource{
  1358. ConfigMap: &config.SchedulerPolicyConfigMapSource{
  1359. Namespace: policyConfigMap.Namespace,
  1360. Name: policyConfigMap.Name,
  1361. },
  1362. },
  1363. }
  1364. informerFactory := informers.NewSharedInformerFactory(client, 0)
  1365. sched, err := scheduler.New(
  1366. client,
  1367. informerFactory,
  1368. informerFactory.Core().V1().Pods(),
  1369. nil,
  1370. make(chan struct{}),
  1371. scheduler.WithAlgorithmSource(algorithmSrc),
  1372. )
  1373. if err != nil {
  1374. t.Fatalf("Error constructing: %v", err)
  1375. }
  1376. gotPlugins := sched.Framework.ListPlugins()
  1377. if diff := cmp.Diff(tc.wantPlugins, gotPlugins); diff != "" {
  1378. t.Errorf("unexpected plugins diff (-want, +got): %s", diff)
  1379. }
  1380. gotExtenders := sched.Algorithm.Extenders()
  1381. var wantExtenders []*core.HTTPExtender
  1382. for _, e := range tc.wantExtenders {
  1383. extender, err := core.NewHTTPExtender(&e)
  1384. if err != nil {
  1385. t.Errorf("Error transforming extender: %+v", e)
  1386. }
  1387. wantExtenders = append(wantExtenders, extender.(*core.HTTPExtender))
  1388. }
  1389. for i := range gotExtenders {
  1390. if !core.Equal(wantExtenders[i], gotExtenders[i].(*core.HTTPExtender)) {
  1391. t.Errorf("Got extender #%d %+v, want %+v", i, gotExtenders[i], wantExtenders[i])
  1392. }
  1393. }
  1394. })
  1395. }
  1396. }
  1397. func TestAlgorithmProviderCompatibility(t *testing.T) {
  1398. // Add serialized versions of scheduler config that exercise available options to ensure compatibility between releases
  1399. defaultPlugins := map[string][]config.Plugin{
  1400. "QueueSortPlugin": {
  1401. {Name: "PrioritySort"},
  1402. },
  1403. "PreFilterPlugin": {
  1404. {Name: "NodeResourcesFit"},
  1405. {Name: "NodePorts"},
  1406. {Name: "InterPodAffinity"},
  1407. {Name: "PodTopologySpread"},
  1408. },
  1409. "FilterPlugin": {
  1410. {Name: "NodeUnschedulable"},
  1411. {Name: "NodeResourcesFit"},
  1412. {Name: "NodeName"},
  1413. {Name: "NodePorts"},
  1414. {Name: "NodeAffinity"},
  1415. {Name: "VolumeRestrictions"},
  1416. {Name: "TaintToleration"},
  1417. {Name: "EBSLimits"},
  1418. {Name: "GCEPDLimits"},
  1419. {Name: "NodeVolumeLimits"},
  1420. {Name: "AzureDiskLimits"},
  1421. {Name: "VolumeBinding"},
  1422. {Name: "VolumeZone"},
  1423. {Name: "InterPodAffinity"},
  1424. {Name: "PodTopologySpread"},
  1425. },
  1426. "PreScorePlugin": {
  1427. {Name: "InterPodAffinity"},
  1428. {Name: "DefaultPodTopologySpread"},
  1429. {Name: "TaintToleration"},
  1430. {Name: "PodTopologySpread"},
  1431. },
  1432. "ScorePlugin": {
  1433. {Name: "NodeResourcesBalancedAllocation", Weight: 1},
  1434. {Name: "ImageLocality", Weight: 1},
  1435. {Name: "InterPodAffinity", Weight: 1},
  1436. {Name: "NodeResourcesLeastAllocated", Weight: 1},
  1437. {Name: "NodeAffinity", Weight: 1},
  1438. {Name: "NodePreferAvoidPods", Weight: 10000},
  1439. {Name: "DefaultPodTopologySpread", Weight: 1},
  1440. {Name: "TaintToleration", Weight: 1},
  1441. {Name: "PodTopologySpread", Weight: 1},
  1442. },
  1443. "BindPlugin": {{Name: "DefaultBinder"}},
  1444. }
  1445. testcases := []struct {
  1446. name string
  1447. provider string
  1448. wantPlugins map[string][]config.Plugin
  1449. }{
  1450. {
  1451. name: "No Provider specified",
  1452. wantPlugins: defaultPlugins,
  1453. },
  1454. {
  1455. name: "DefaultProvider",
  1456. provider: config.SchedulerDefaultProviderName,
  1457. wantPlugins: defaultPlugins,
  1458. },
  1459. {
  1460. name: "ClusterAutoscalerProvider",
  1461. provider: algorithmprovider.ClusterAutoscalerProvider,
  1462. wantPlugins: map[string][]config.Plugin{
  1463. "QueueSortPlugin": {
  1464. {Name: "PrioritySort"},
  1465. },
  1466. "PreFilterPlugin": {
  1467. {Name: "NodeResourcesFit"},
  1468. {Name: "NodePorts"},
  1469. {Name: "InterPodAffinity"},
  1470. {Name: "PodTopologySpread"},
  1471. },
  1472. "FilterPlugin": {
  1473. {Name: "NodeUnschedulable"},
  1474. {Name: "NodeResourcesFit"},
  1475. {Name: "NodeName"},
  1476. {Name: "NodePorts"},
  1477. {Name: "NodeAffinity"},
  1478. {Name: "VolumeRestrictions"},
  1479. {Name: "TaintToleration"},
  1480. {Name: "EBSLimits"},
  1481. {Name: "GCEPDLimits"},
  1482. {Name: "NodeVolumeLimits"},
  1483. {Name: "AzureDiskLimits"},
  1484. {Name: "VolumeBinding"},
  1485. {Name: "VolumeZone"},
  1486. {Name: "InterPodAffinity"},
  1487. {Name: "PodTopologySpread"},
  1488. },
  1489. "PreScorePlugin": {
  1490. {Name: "InterPodAffinity"},
  1491. {Name: "DefaultPodTopologySpread"},
  1492. {Name: "TaintToleration"},
  1493. {Name: "PodTopologySpread"},
  1494. },
  1495. "ScorePlugin": {
  1496. {Name: "NodeResourcesBalancedAllocation", Weight: 1},
  1497. {Name: "ImageLocality", Weight: 1},
  1498. {Name: "InterPodAffinity", Weight: 1},
  1499. {Name: "NodeResourcesMostAllocated", Weight: 1},
  1500. {Name: "NodeAffinity", Weight: 1},
  1501. {Name: "NodePreferAvoidPods", Weight: 10000},
  1502. {Name: "DefaultPodTopologySpread", Weight: 1},
  1503. {Name: "TaintToleration", Weight: 1},
  1504. {Name: "PodTopologySpread", Weight: 1},
  1505. },
  1506. "BindPlugin": {{Name: "DefaultBinder"}},
  1507. },
  1508. },
  1509. }
  1510. for _, tc := range testcases {
  1511. t.Run(tc.name, func(t *testing.T) {
  1512. var opts []scheduler.Option
  1513. if len(tc.provider) != 0 {
  1514. opts = append(opts, scheduler.WithAlgorithmSource(config.SchedulerAlgorithmSource{
  1515. Provider: &tc.provider,
  1516. }))
  1517. }
  1518. client := fake.NewSimpleClientset()
  1519. informerFactory := informers.NewSharedInformerFactory(client, 0)
  1520. sched, err := scheduler.New(
  1521. client,
  1522. informerFactory,
  1523. informerFactory.Core().V1().Pods(),
  1524. nil,
  1525. make(chan struct{}),
  1526. opts...,
  1527. )
  1528. if err != nil {
  1529. t.Fatalf("Error constructing: %v", err)
  1530. }
  1531. gotPlugins := sched.Framework.ListPlugins()
  1532. if diff := cmp.Diff(tc.wantPlugins, gotPlugins); diff != "" {
  1533. t.Errorf("unexpected plugins diff (-want, +got): %s", diff)
  1534. }
  1535. })
  1536. }
  1537. }