compatibility_test.go 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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 compatibility
  14. import (
  15. "fmt"
  16. "net/http/httptest"
  17. "reflect"
  18. "testing"
  19. "k8s.io/api/core/v1"
  20. "k8s.io/apimachinery/pkg/runtime"
  21. "k8s.io/apimachinery/pkg/runtime/schema"
  22. "k8s.io/apimachinery/pkg/util/sets"
  23. "k8s.io/client-go/informers"
  24. clientset "k8s.io/client-go/kubernetes"
  25. restclient "k8s.io/client-go/rest"
  26. utiltesting "k8s.io/client-go/util/testing"
  27. _ "k8s.io/kubernetes/pkg/apis/core/install"
  28. _ "k8s.io/kubernetes/pkg/scheduler/algorithmprovider/defaults"
  29. schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
  30. latestschedulerapi "k8s.io/kubernetes/pkg/scheduler/api/latest"
  31. "k8s.io/kubernetes/pkg/scheduler/factory"
  32. )
  33. func TestCompatibility_v1_Scheduler(t *testing.T) {
  34. // Add serialized versions of scheduler config that exercise available options to ensure compatibility between releases
  35. schedulerFiles := map[string]struct {
  36. JSON string
  37. ExpectedPolicy schedulerapi.Policy
  38. }{
  39. // Do not change this JSON after the corresponding release has been tagged.
  40. // A failure indicates backwards compatibility with the specified release was broken.
  41. "1.0": {
  42. JSON: `{
  43. "kind": "Policy",
  44. "apiVersion": "v1",
  45. "predicates": [
  46. {"name": "MatchNodeSelector"},
  47. {"name": "PodFitsResources"},
  48. {"name": "PodFitsPorts"},
  49. {"name": "NoDiskConflict"},
  50. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  51. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  52. ],"priorities": [
  53. {"name": "LeastRequestedPriority", "weight": 1},
  54. {"name": "ServiceSpreadingPriority", "weight": 2},
  55. {"name": "TestServiceAntiAffinity", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  56. {"name": "TestLabelPreference", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}}
  57. ]
  58. }`,
  59. ExpectedPolicy: schedulerapi.Policy{
  60. Predicates: []schedulerapi.PredicatePolicy{
  61. {Name: "MatchNodeSelector"},
  62. {Name: "PodFitsResources"},
  63. {Name: "PodFitsPorts"},
  64. {Name: "NoDiskConflict"},
  65. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  66. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  67. },
  68. Priorities: []schedulerapi.PriorityPolicy{
  69. {Name: "LeastRequestedPriority", Weight: 1},
  70. {Name: "ServiceSpreadingPriority", Weight: 2},
  71. {Name: "TestServiceAntiAffinity", Weight: 3, Argument: &schedulerapi.PriorityArgument{ServiceAntiAffinity: &schedulerapi.ServiceAntiAffinity{Label: "zone"}}},
  72. {Name: "TestLabelPreference", Weight: 4, Argument: &schedulerapi.PriorityArgument{LabelPreference: &schedulerapi.LabelPreference{Label: "bar", Presence: true}}},
  73. },
  74. },
  75. },
  76. // Do not change this JSON after the corresponding release has been tagged.
  77. // A failure indicates backwards compatibility with the specified release was broken.
  78. "1.1": {
  79. JSON: `{
  80. "kind": "Policy",
  81. "apiVersion": "v1",
  82. "predicates": [
  83. {"name": "MatchNodeSelector"},
  84. {"name": "PodFitsHostPorts"},
  85. {"name": "PodFitsResources"},
  86. {"name": "NoDiskConflict"},
  87. {"name": "HostName"},
  88. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  89. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  90. ],"priorities": [
  91. {"name": "EqualPriority", "weight": 2},
  92. {"name": "LeastRequestedPriority", "weight": 2},
  93. {"name": "BalancedResourceAllocation", "weight": 2},
  94. {"name": "SelectorSpreadPriority", "weight": 2},
  95. {"name": "TestServiceAntiAffinity", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  96. {"name": "TestLabelPreference", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}}
  97. ]
  98. }`,
  99. ExpectedPolicy: schedulerapi.Policy{
  100. Predicates: []schedulerapi.PredicatePolicy{
  101. {Name: "MatchNodeSelector"},
  102. {Name: "PodFitsHostPorts"},
  103. {Name: "PodFitsResources"},
  104. {Name: "NoDiskConflict"},
  105. {Name: "HostName"},
  106. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  107. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  108. },
  109. Priorities: []schedulerapi.PriorityPolicy{
  110. {Name: "EqualPriority", Weight: 2},
  111. {Name: "LeastRequestedPriority", Weight: 2},
  112. {Name: "BalancedResourceAllocation", Weight: 2},
  113. {Name: "SelectorSpreadPriority", Weight: 2},
  114. {Name: "TestServiceAntiAffinity", Weight: 3, Argument: &schedulerapi.PriorityArgument{ServiceAntiAffinity: &schedulerapi.ServiceAntiAffinity{Label: "zone"}}},
  115. {Name: "TestLabelPreference", Weight: 4, Argument: &schedulerapi.PriorityArgument{LabelPreference: &schedulerapi.LabelPreference{Label: "bar", Presence: true}}},
  116. },
  117. },
  118. },
  119. // Do not change this JSON after the corresponding release has been tagged.
  120. // A failure indicates backwards compatibility with the specified release was broken.
  121. "1.2": {
  122. JSON: `{
  123. "kind": "Policy",
  124. "apiVersion": "v1",
  125. "predicates": [
  126. {"name": "MatchNodeSelector"},
  127. {"name": "PodFitsResources"},
  128. {"name": "PodFitsHostPorts"},
  129. {"name": "HostName"},
  130. {"name": "NoDiskConflict"},
  131. {"name": "NoVolumeZoneConflict"},
  132. {"name": "MaxEBSVolumeCount"},
  133. {"name": "MaxGCEPDVolumeCount"},
  134. {"name": "MaxAzureDiskVolumeCount"},
  135. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  136. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  137. ],"priorities": [
  138. {"name": "EqualPriority", "weight": 2},
  139. {"name": "NodeAffinityPriority", "weight": 2},
  140. {"name": "ImageLocalityPriority", "weight": 2},
  141. {"name": "LeastRequestedPriority", "weight": 2},
  142. {"name": "BalancedResourceAllocation", "weight": 2},
  143. {"name": "SelectorSpreadPriority", "weight": 2},
  144. {"name": "TestServiceAntiAffinity", "weight": 3, "argument": {"serviceAntiAffinity": {"label": "zone"}}},
  145. {"name": "TestLabelPreference", "weight": 4, "argument": {"labelPreference": {"label": "bar", "presence":true}}}
  146. ]
  147. }`,
  148. ExpectedPolicy: schedulerapi.Policy{
  149. Predicates: []schedulerapi.PredicatePolicy{
  150. {Name: "MatchNodeSelector"},
  151. {Name: "PodFitsResources"},
  152. {Name: "PodFitsHostPorts"},
  153. {Name: "HostName"},
  154. {Name: "NoDiskConflict"},
  155. {Name: "NoVolumeZoneConflict"},
  156. {Name: "MaxEBSVolumeCount"},
  157. {Name: "MaxGCEPDVolumeCount"},
  158. {Name: "MaxAzureDiskVolumeCount"},
  159. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  160. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  161. },
  162. Priorities: []schedulerapi.PriorityPolicy{
  163. {Name: "EqualPriority", Weight: 2},
  164. {Name: "NodeAffinityPriority", Weight: 2},
  165. {Name: "ImageLocalityPriority", Weight: 2},
  166. {Name: "LeastRequestedPriority", Weight: 2},
  167. {Name: "BalancedResourceAllocation", Weight: 2},
  168. {Name: "SelectorSpreadPriority", Weight: 2},
  169. {Name: "TestServiceAntiAffinity", Weight: 3, Argument: &schedulerapi.PriorityArgument{ServiceAntiAffinity: &schedulerapi.ServiceAntiAffinity{Label: "zone"}}},
  170. {Name: "TestLabelPreference", Weight: 4, Argument: &schedulerapi.PriorityArgument{LabelPreference: &schedulerapi.LabelPreference{Label: "bar", Presence: true}}},
  171. },
  172. },
  173. },
  174. // Do not change this JSON after the corresponding release has been tagged.
  175. // A failure indicates backwards compatibility with the specified release was broken.
  176. "1.3": {
  177. JSON: `{
  178. "kind": "Policy",
  179. "apiVersion": "v1",
  180. "predicates": [
  181. {"name": "MatchNodeSelector"},
  182. {"name": "PodFitsResources"},
  183. {"name": "PodFitsHostPorts"},
  184. {"name": "HostName"},
  185. {"name": "NoDiskConflict"},
  186. {"name": "NoVolumeZoneConflict"},
  187. {"name": "PodToleratesNodeTaints"},
  188. {"name": "CheckNodeMemoryPressure"},
  189. {"name": "MaxEBSVolumeCount"},
  190. {"name": "MaxGCEPDVolumeCount"},
  191. {"name": "MaxAzureDiskVolumeCount"},
  192. {"name": "MatchInterPodAffinity"},
  193. {"name": "GeneralPredicates"},
  194. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  195. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  196. ],"priorities": [
  197. {"name": "EqualPriority", "weight": 2},
  198. {"name": "ImageLocalityPriority", "weight": 2},
  199. {"name": "LeastRequestedPriority", "weight": 2},
  200. {"name": "BalancedResourceAllocation", "weight": 2},
  201. {"name": "SelectorSpreadPriority", "weight": 2},
  202. {"name": "NodeAffinityPriority", "weight": 2},
  203. {"name": "TaintTolerationPriority", "weight": 2},
  204. {"name": "InterPodAffinityPriority", "weight": 2}
  205. ]
  206. }`,
  207. ExpectedPolicy: schedulerapi.Policy{
  208. Predicates: []schedulerapi.PredicatePolicy{
  209. {Name: "MatchNodeSelector"},
  210. {Name: "PodFitsResources"},
  211. {Name: "PodFitsHostPorts"},
  212. {Name: "HostName"},
  213. {Name: "NoDiskConflict"},
  214. {Name: "NoVolumeZoneConflict"},
  215. {Name: "PodToleratesNodeTaints"},
  216. {Name: "CheckNodeMemoryPressure"},
  217. {Name: "MaxEBSVolumeCount"},
  218. {Name: "MaxGCEPDVolumeCount"},
  219. {Name: "MaxAzureDiskVolumeCount"},
  220. {Name: "MatchInterPodAffinity"},
  221. {Name: "GeneralPredicates"},
  222. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  223. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  224. },
  225. Priorities: []schedulerapi.PriorityPolicy{
  226. {Name: "EqualPriority", Weight: 2},
  227. {Name: "ImageLocalityPriority", Weight: 2},
  228. {Name: "LeastRequestedPriority", Weight: 2},
  229. {Name: "BalancedResourceAllocation", Weight: 2},
  230. {Name: "SelectorSpreadPriority", Weight: 2},
  231. {Name: "NodeAffinityPriority", Weight: 2},
  232. {Name: "TaintTolerationPriority", Weight: 2},
  233. {Name: "InterPodAffinityPriority", Weight: 2},
  234. },
  235. },
  236. },
  237. // Do not change this JSON after the corresponding release has been tagged.
  238. // A failure indicates backwards compatibility with the specified release was broken.
  239. "1.4": {
  240. JSON: `{
  241. "kind": "Policy",
  242. "apiVersion": "v1",
  243. "predicates": [
  244. {"name": "MatchNodeSelector"},
  245. {"name": "PodFitsResources"},
  246. {"name": "PodFitsHostPorts"},
  247. {"name": "HostName"},
  248. {"name": "NoDiskConflict"},
  249. {"name": "NoVolumeZoneConflict"},
  250. {"name": "PodToleratesNodeTaints"},
  251. {"name": "CheckNodeMemoryPressure"},
  252. {"name": "CheckNodeDiskPressure"},
  253. {"name": "MaxEBSVolumeCount"},
  254. {"name": "MaxGCEPDVolumeCount"},
  255. {"name": "MaxAzureDiskVolumeCount"},
  256. {"name": "MatchInterPodAffinity"},
  257. {"name": "GeneralPredicates"},
  258. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  259. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  260. ],"priorities": [
  261. {"name": "EqualPriority", "weight": 2},
  262. {"name": "ImageLocalityPriority", "weight": 2},
  263. {"name": "LeastRequestedPriority", "weight": 2},
  264. {"name": "BalancedResourceAllocation", "weight": 2},
  265. {"name": "SelectorSpreadPriority", "weight": 2},
  266. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  267. {"name": "NodeAffinityPriority", "weight": 2},
  268. {"name": "TaintTolerationPriority", "weight": 2},
  269. {"name": "InterPodAffinityPriority", "weight": 2},
  270. {"name": "MostRequestedPriority", "weight": 2}
  271. ]
  272. }`,
  273. ExpectedPolicy: schedulerapi.Policy{
  274. Predicates: []schedulerapi.PredicatePolicy{
  275. {Name: "MatchNodeSelector"},
  276. {Name: "PodFitsResources"},
  277. {Name: "PodFitsHostPorts"},
  278. {Name: "HostName"},
  279. {Name: "NoDiskConflict"},
  280. {Name: "NoVolumeZoneConflict"},
  281. {Name: "PodToleratesNodeTaints"},
  282. {Name: "CheckNodeMemoryPressure"},
  283. {Name: "CheckNodeDiskPressure"},
  284. {Name: "MaxEBSVolumeCount"},
  285. {Name: "MaxGCEPDVolumeCount"},
  286. {Name: "MaxAzureDiskVolumeCount"},
  287. {Name: "MatchInterPodAffinity"},
  288. {Name: "GeneralPredicates"},
  289. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  290. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  291. },
  292. Priorities: []schedulerapi.PriorityPolicy{
  293. {Name: "EqualPriority", Weight: 2},
  294. {Name: "ImageLocalityPriority", Weight: 2},
  295. {Name: "LeastRequestedPriority", Weight: 2},
  296. {Name: "BalancedResourceAllocation", Weight: 2},
  297. {Name: "SelectorSpreadPriority", Weight: 2},
  298. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  299. {Name: "NodeAffinityPriority", Weight: 2},
  300. {Name: "TaintTolerationPriority", Weight: 2},
  301. {Name: "InterPodAffinityPriority", Weight: 2},
  302. {Name: "MostRequestedPriority", Weight: 2},
  303. },
  304. },
  305. },
  306. // Do not change this JSON after the corresponding release has been tagged.
  307. // A failure indicates backwards compatibility with the specified release was broken.
  308. "1.7": {
  309. JSON: `{
  310. "kind": "Policy",
  311. "apiVersion": "v1",
  312. "predicates": [
  313. {"name": "MatchNodeSelector"},
  314. {"name": "PodFitsResources"},
  315. {"name": "PodFitsHostPorts"},
  316. {"name": "HostName"},
  317. {"name": "NoDiskConflict"},
  318. {"name": "NoVolumeZoneConflict"},
  319. {"name": "PodToleratesNodeTaints"},
  320. {"name": "CheckNodeMemoryPressure"},
  321. {"name": "CheckNodeDiskPressure"},
  322. {"name": "MaxEBSVolumeCount"},
  323. {"name": "MaxGCEPDVolumeCount"},
  324. {"name": "MaxAzureDiskVolumeCount"},
  325. {"name": "MatchInterPodAffinity"},
  326. {"name": "GeneralPredicates"},
  327. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  328. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  329. ],"priorities": [
  330. {"name": "EqualPriority", "weight": 2},
  331. {"name": "ImageLocalityPriority", "weight": 2},
  332. {"name": "LeastRequestedPriority", "weight": 2},
  333. {"name": "BalancedResourceAllocation", "weight": 2},
  334. {"name": "SelectorSpreadPriority", "weight": 2},
  335. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  336. {"name": "NodeAffinityPriority", "weight": 2},
  337. {"name": "TaintTolerationPriority", "weight": 2},
  338. {"name": "InterPodAffinityPriority", "weight": 2},
  339. {"name": "MostRequestedPriority", "weight": 2}
  340. ],"extenders": [{
  341. "urlPrefix": "/prefix",
  342. "filterVerb": "filter",
  343. "prioritizeVerb": "prioritize",
  344. "weight": 1,
  345. "BindVerb": "bind",
  346. "enableHttps": true,
  347. "tlsConfig": {"Insecure":true},
  348. "httpTimeout": 1,
  349. "nodeCacheCapable": true
  350. }]
  351. }`,
  352. ExpectedPolicy: schedulerapi.Policy{
  353. Predicates: []schedulerapi.PredicatePolicy{
  354. {Name: "MatchNodeSelector"},
  355. {Name: "PodFitsResources"},
  356. {Name: "PodFitsHostPorts"},
  357. {Name: "HostName"},
  358. {Name: "NoDiskConflict"},
  359. {Name: "NoVolumeZoneConflict"},
  360. {Name: "PodToleratesNodeTaints"},
  361. {Name: "CheckNodeMemoryPressure"},
  362. {Name: "CheckNodeDiskPressure"},
  363. {Name: "MaxEBSVolumeCount"},
  364. {Name: "MaxGCEPDVolumeCount"},
  365. {Name: "MaxAzureDiskVolumeCount"},
  366. {Name: "MatchInterPodAffinity"},
  367. {Name: "GeneralPredicates"},
  368. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  369. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  370. },
  371. Priorities: []schedulerapi.PriorityPolicy{
  372. {Name: "EqualPriority", Weight: 2},
  373. {Name: "ImageLocalityPriority", Weight: 2},
  374. {Name: "LeastRequestedPriority", Weight: 2},
  375. {Name: "BalancedResourceAllocation", Weight: 2},
  376. {Name: "SelectorSpreadPriority", Weight: 2},
  377. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  378. {Name: "NodeAffinityPriority", Weight: 2},
  379. {Name: "TaintTolerationPriority", Weight: 2},
  380. {Name: "InterPodAffinityPriority", Weight: 2},
  381. {Name: "MostRequestedPriority", Weight: 2},
  382. },
  383. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  384. URLPrefix: "/prefix",
  385. FilterVerb: "filter",
  386. PrioritizeVerb: "prioritize",
  387. Weight: 1,
  388. BindVerb: "bind", // 1.7 was missing json tags on the BindVerb field and required "BindVerb"
  389. EnableHTTPS: true,
  390. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  391. HTTPTimeout: 1,
  392. NodeCacheCapable: true,
  393. }},
  394. },
  395. },
  396. // Do not change this JSON after the corresponding release has been tagged.
  397. // A failure indicates backwards compatibility with the specified release was broken.
  398. "1.8": {
  399. JSON: `{
  400. "kind": "Policy",
  401. "apiVersion": "v1",
  402. "predicates": [
  403. {"name": "MatchNodeSelector"},
  404. {"name": "PodFitsResources"},
  405. {"name": "PodFitsHostPorts"},
  406. {"name": "HostName"},
  407. {"name": "NoDiskConflict"},
  408. {"name": "NoVolumeZoneConflict"},
  409. {"name": "PodToleratesNodeTaints"},
  410. {"name": "CheckNodeMemoryPressure"},
  411. {"name": "CheckNodeDiskPressure"},
  412. {"name": "CheckNodeCondition"},
  413. {"name": "MaxEBSVolumeCount"},
  414. {"name": "MaxGCEPDVolumeCount"},
  415. {"name": "MaxAzureDiskVolumeCount"},
  416. {"name": "MatchInterPodAffinity"},
  417. {"name": "GeneralPredicates"},
  418. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  419. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  420. ],"priorities": [
  421. {"name": "EqualPriority", "weight": 2},
  422. {"name": "ImageLocalityPriority", "weight": 2},
  423. {"name": "LeastRequestedPriority", "weight": 2},
  424. {"name": "BalancedResourceAllocation", "weight": 2},
  425. {"name": "SelectorSpreadPriority", "weight": 2},
  426. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  427. {"name": "NodeAffinityPriority", "weight": 2},
  428. {"name": "TaintTolerationPriority", "weight": 2},
  429. {"name": "InterPodAffinityPriority", "weight": 2},
  430. {"name": "MostRequestedPriority", "weight": 2}
  431. ],"extenders": [{
  432. "urlPrefix": "/prefix",
  433. "filterVerb": "filter",
  434. "prioritizeVerb": "prioritize",
  435. "weight": 1,
  436. "bindVerb": "bind",
  437. "enableHttps": true,
  438. "tlsConfig": {"Insecure":true},
  439. "httpTimeout": 1,
  440. "nodeCacheCapable": true
  441. }]
  442. }`,
  443. ExpectedPolicy: schedulerapi.Policy{
  444. Predicates: []schedulerapi.PredicatePolicy{
  445. {Name: "MatchNodeSelector"},
  446. {Name: "PodFitsResources"},
  447. {Name: "PodFitsHostPorts"},
  448. {Name: "HostName"},
  449. {Name: "NoDiskConflict"},
  450. {Name: "NoVolumeZoneConflict"},
  451. {Name: "PodToleratesNodeTaints"},
  452. {Name: "CheckNodeMemoryPressure"},
  453. {Name: "CheckNodeDiskPressure"},
  454. {Name: "CheckNodeCondition"},
  455. {Name: "MaxEBSVolumeCount"},
  456. {Name: "MaxGCEPDVolumeCount"},
  457. {Name: "MaxAzureDiskVolumeCount"},
  458. {Name: "MatchInterPodAffinity"},
  459. {Name: "GeneralPredicates"},
  460. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  461. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  462. },
  463. Priorities: []schedulerapi.PriorityPolicy{
  464. {Name: "EqualPriority", Weight: 2},
  465. {Name: "ImageLocalityPriority", Weight: 2},
  466. {Name: "LeastRequestedPriority", Weight: 2},
  467. {Name: "BalancedResourceAllocation", Weight: 2},
  468. {Name: "SelectorSpreadPriority", Weight: 2},
  469. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  470. {Name: "NodeAffinityPriority", Weight: 2},
  471. {Name: "TaintTolerationPriority", Weight: 2},
  472. {Name: "InterPodAffinityPriority", Weight: 2},
  473. {Name: "MostRequestedPriority", Weight: 2},
  474. },
  475. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  476. URLPrefix: "/prefix",
  477. FilterVerb: "filter",
  478. PrioritizeVerb: "prioritize",
  479. Weight: 1,
  480. BindVerb: "bind", // 1.8 became case-insensitive and tolerated "bindVerb"
  481. EnableHTTPS: true,
  482. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  483. HTTPTimeout: 1,
  484. NodeCacheCapable: true,
  485. }},
  486. },
  487. },
  488. // Do not change this JSON after the corresponding release has been tagged.
  489. // A failure indicates backwards compatibility with the specified release was broken.
  490. "1.9": {
  491. JSON: `{
  492. "kind": "Policy",
  493. "apiVersion": "v1",
  494. "predicates": [
  495. {"name": "MatchNodeSelector"},
  496. {"name": "PodFitsResources"},
  497. {"name": "PodFitsHostPorts"},
  498. {"name": "HostName"},
  499. {"name": "NoDiskConflict"},
  500. {"name": "NoVolumeZoneConflict"},
  501. {"name": "PodToleratesNodeTaints"},
  502. {"name": "CheckNodeMemoryPressure"},
  503. {"name": "CheckNodeDiskPressure"},
  504. {"name": "CheckNodeCondition"},
  505. {"name": "MaxEBSVolumeCount"},
  506. {"name": "MaxGCEPDVolumeCount"},
  507. {"name": "MaxAzureDiskVolumeCount"},
  508. {"name": "MatchInterPodAffinity"},
  509. {"name": "GeneralPredicates"},
  510. {"name": "CheckVolumeBinding"},
  511. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  512. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  513. ],"priorities": [
  514. {"name": "EqualPriority", "weight": 2},
  515. {"name": "ImageLocalityPriority", "weight": 2},
  516. {"name": "LeastRequestedPriority", "weight": 2},
  517. {"name": "BalancedResourceAllocation", "weight": 2},
  518. {"name": "SelectorSpreadPriority", "weight": 2},
  519. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  520. {"name": "NodeAffinityPriority", "weight": 2},
  521. {"name": "TaintTolerationPriority", "weight": 2},
  522. {"name": "InterPodAffinityPriority", "weight": 2},
  523. {"name": "MostRequestedPriority", "weight": 2}
  524. ],"extenders": [{
  525. "urlPrefix": "/prefix",
  526. "filterVerb": "filter",
  527. "prioritizeVerb": "prioritize",
  528. "weight": 1,
  529. "bindVerb": "bind",
  530. "enableHttps": true,
  531. "tlsConfig": {"Insecure":true},
  532. "httpTimeout": 1,
  533. "nodeCacheCapable": true
  534. }]
  535. }`,
  536. ExpectedPolicy: schedulerapi.Policy{
  537. Predicates: []schedulerapi.PredicatePolicy{
  538. {Name: "MatchNodeSelector"},
  539. {Name: "PodFitsResources"},
  540. {Name: "PodFitsHostPorts"},
  541. {Name: "HostName"},
  542. {Name: "NoDiskConflict"},
  543. {Name: "NoVolumeZoneConflict"},
  544. {Name: "PodToleratesNodeTaints"},
  545. {Name: "CheckNodeMemoryPressure"},
  546. {Name: "CheckNodeDiskPressure"},
  547. {Name: "CheckNodeCondition"},
  548. {Name: "MaxEBSVolumeCount"},
  549. {Name: "MaxGCEPDVolumeCount"},
  550. {Name: "MaxAzureDiskVolumeCount"},
  551. {Name: "MatchInterPodAffinity"},
  552. {Name: "GeneralPredicates"},
  553. {Name: "CheckVolumeBinding"},
  554. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  555. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  556. },
  557. Priorities: []schedulerapi.PriorityPolicy{
  558. {Name: "EqualPriority", Weight: 2},
  559. {Name: "ImageLocalityPriority", Weight: 2},
  560. {Name: "LeastRequestedPriority", Weight: 2},
  561. {Name: "BalancedResourceAllocation", Weight: 2},
  562. {Name: "SelectorSpreadPriority", Weight: 2},
  563. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  564. {Name: "NodeAffinityPriority", Weight: 2},
  565. {Name: "TaintTolerationPriority", Weight: 2},
  566. {Name: "InterPodAffinityPriority", Weight: 2},
  567. {Name: "MostRequestedPriority", Weight: 2},
  568. },
  569. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  570. URLPrefix: "/prefix",
  571. FilterVerb: "filter",
  572. PrioritizeVerb: "prioritize",
  573. Weight: 1,
  574. BindVerb: "bind", // 1.9 was case-insensitive and tolerated "bindVerb"
  575. EnableHTTPS: true,
  576. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  577. HTTPTimeout: 1,
  578. NodeCacheCapable: true,
  579. }},
  580. },
  581. },
  582. // Do not change this JSON after the corresponding release has been tagged.
  583. // A failure indicates backwards compatibility with the specified release was broken.
  584. "1.10": {
  585. JSON: `{
  586. "kind": "Policy",
  587. "apiVersion": "v1",
  588. "predicates": [
  589. {"name": "MatchNodeSelector"},
  590. {"name": "PodFitsResources"},
  591. {"name": "PodFitsHostPorts"},
  592. {"name": "HostName"},
  593. {"name": "NoDiskConflict"},
  594. {"name": "NoVolumeZoneConflict"},
  595. {"name": "PodToleratesNodeTaints"},
  596. {"name": "CheckNodeMemoryPressure"},
  597. {"name": "CheckNodeDiskPressure"},
  598. {"name": "CheckNodePIDPressure"},
  599. {"name": "CheckNodeCondition"},
  600. {"name": "MaxEBSVolumeCount"},
  601. {"name": "MaxGCEPDVolumeCount"},
  602. {"name": "MaxAzureDiskVolumeCount"},
  603. {"name": "MatchInterPodAffinity"},
  604. {"name": "GeneralPredicates"},
  605. {"name": "CheckVolumeBinding"},
  606. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  607. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  608. ],"priorities": [
  609. {"name": "EqualPriority", "weight": 2},
  610. {"name": "ImageLocalityPriority", "weight": 2},
  611. {"name": "LeastRequestedPriority", "weight": 2},
  612. {"name": "BalancedResourceAllocation", "weight": 2},
  613. {"name": "SelectorSpreadPriority", "weight": 2},
  614. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  615. {"name": "NodeAffinityPriority", "weight": 2},
  616. {"name": "TaintTolerationPriority", "weight": 2},
  617. {"name": "InterPodAffinityPriority", "weight": 2},
  618. {"name": "MostRequestedPriority", "weight": 2}
  619. ],"extenders": [{
  620. "urlPrefix": "/prefix",
  621. "filterVerb": "filter",
  622. "prioritizeVerb": "prioritize",
  623. "weight": 1,
  624. "bindVerb": "bind",
  625. "enableHttps": true,
  626. "tlsConfig": {"Insecure":true},
  627. "httpTimeout": 1,
  628. "nodeCacheCapable": true,
  629. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  630. "ignorable":true
  631. }]
  632. }`,
  633. ExpectedPolicy: schedulerapi.Policy{
  634. Predicates: []schedulerapi.PredicatePolicy{
  635. {Name: "MatchNodeSelector"},
  636. {Name: "PodFitsResources"},
  637. {Name: "PodFitsHostPorts"},
  638. {Name: "HostName"},
  639. {Name: "NoDiskConflict"},
  640. {Name: "NoVolumeZoneConflict"},
  641. {Name: "PodToleratesNodeTaints"},
  642. {Name: "CheckNodeMemoryPressure"},
  643. {Name: "CheckNodeDiskPressure"},
  644. {Name: "CheckNodePIDPressure"},
  645. {Name: "CheckNodeCondition"},
  646. {Name: "MaxEBSVolumeCount"},
  647. {Name: "MaxGCEPDVolumeCount"},
  648. {Name: "MaxAzureDiskVolumeCount"},
  649. {Name: "MatchInterPodAffinity"},
  650. {Name: "GeneralPredicates"},
  651. {Name: "CheckVolumeBinding"},
  652. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  653. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  654. },
  655. Priorities: []schedulerapi.PriorityPolicy{
  656. {Name: "EqualPriority", Weight: 2},
  657. {Name: "ImageLocalityPriority", Weight: 2},
  658. {Name: "LeastRequestedPriority", Weight: 2},
  659. {Name: "BalancedResourceAllocation", Weight: 2},
  660. {Name: "SelectorSpreadPriority", Weight: 2},
  661. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  662. {Name: "NodeAffinityPriority", Weight: 2},
  663. {Name: "TaintTolerationPriority", Weight: 2},
  664. {Name: "InterPodAffinityPriority", Weight: 2},
  665. {Name: "MostRequestedPriority", Weight: 2},
  666. },
  667. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  668. URLPrefix: "/prefix",
  669. FilterVerb: "filter",
  670. PrioritizeVerb: "prioritize",
  671. Weight: 1,
  672. BindVerb: "bind", // 1.10 was case-insensitive and tolerated "bindVerb"
  673. EnableHTTPS: true,
  674. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  675. HTTPTimeout: 1,
  676. NodeCacheCapable: true,
  677. ManagedResources: []schedulerapi.ExtenderManagedResource{{Name: v1.ResourceName("example.com/foo"), IgnoredByScheduler: true}},
  678. Ignorable: true,
  679. }},
  680. },
  681. },
  682. // Do not change this JSON after the corresponding release has been tagged.
  683. // A failure indicates backwards compatibility with the specified release was broken.
  684. "1.11": {
  685. JSON: `{
  686. "kind": "Policy",
  687. "apiVersion": "v1",
  688. "predicates": [
  689. {"name": "MatchNodeSelector"},
  690. {"name": "PodFitsResources"},
  691. {"name": "PodFitsHostPorts"},
  692. {"name": "HostName"},
  693. {"name": "NoDiskConflict"},
  694. {"name": "NoVolumeZoneConflict"},
  695. {"name": "PodToleratesNodeTaints"},
  696. {"name": "CheckNodeMemoryPressure"},
  697. {"name": "CheckNodeDiskPressure"},
  698. {"name": "CheckNodePIDPressure"},
  699. {"name": "CheckNodeCondition"},
  700. {"name": "MaxEBSVolumeCount"},
  701. {"name": "MaxGCEPDVolumeCount"},
  702. {"name": "MaxAzureDiskVolumeCount"},
  703. {"name": "MatchInterPodAffinity"},
  704. {"name": "GeneralPredicates"},
  705. {"name": "CheckVolumeBinding"},
  706. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  707. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  708. ],"priorities": [
  709. {"name": "EqualPriority", "weight": 2},
  710. {"name": "ImageLocalityPriority", "weight": 2},
  711. {"name": "LeastRequestedPriority", "weight": 2},
  712. {"name": "BalancedResourceAllocation", "weight": 2},
  713. {"name": "SelectorSpreadPriority", "weight": 2},
  714. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  715. {"name": "NodeAffinityPriority", "weight": 2},
  716. {"name": "TaintTolerationPriority", "weight": 2},
  717. {"name": "InterPodAffinityPriority", "weight": 2},
  718. {"name": "MostRequestedPriority", "weight": 2},
  719. {
  720. "name": "RequestedToCapacityRatioPriority",
  721. "weight": 2,
  722. "argument": {
  723. "requestedToCapacityRatioArguments": {
  724. "shape": [
  725. {"utilization": 0, "score": 0},
  726. {"utilization": 50, "score": 7}
  727. ]
  728. }
  729. }}
  730. ],"extenders": [{
  731. "urlPrefix": "/prefix",
  732. "filterVerb": "filter",
  733. "prioritizeVerb": "prioritize",
  734. "weight": 1,
  735. "bindVerb": "bind",
  736. "enableHttps": true,
  737. "tlsConfig": {"Insecure":true},
  738. "httpTimeout": 1,
  739. "nodeCacheCapable": true,
  740. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  741. "ignorable":true
  742. }]
  743. }`,
  744. ExpectedPolicy: schedulerapi.Policy{
  745. Predicates: []schedulerapi.PredicatePolicy{
  746. {Name: "MatchNodeSelector"},
  747. {Name: "PodFitsResources"},
  748. {Name: "PodFitsHostPorts"},
  749. {Name: "HostName"},
  750. {Name: "NoDiskConflict"},
  751. {Name: "NoVolumeZoneConflict"},
  752. {Name: "PodToleratesNodeTaints"},
  753. {Name: "CheckNodeMemoryPressure"},
  754. {Name: "CheckNodeDiskPressure"},
  755. {Name: "CheckNodePIDPressure"},
  756. {Name: "CheckNodeCondition"},
  757. {Name: "MaxEBSVolumeCount"},
  758. {Name: "MaxGCEPDVolumeCount"},
  759. {Name: "MaxAzureDiskVolumeCount"},
  760. {Name: "MatchInterPodAffinity"},
  761. {Name: "GeneralPredicates"},
  762. {Name: "CheckVolumeBinding"},
  763. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  764. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  765. },
  766. Priorities: []schedulerapi.PriorityPolicy{
  767. {Name: "EqualPriority", Weight: 2},
  768. {Name: "ImageLocalityPriority", Weight: 2},
  769. {Name: "LeastRequestedPriority", Weight: 2},
  770. {Name: "BalancedResourceAllocation", Weight: 2},
  771. {Name: "SelectorSpreadPriority", Weight: 2},
  772. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  773. {Name: "NodeAffinityPriority", Weight: 2},
  774. {Name: "TaintTolerationPriority", Weight: 2},
  775. {Name: "InterPodAffinityPriority", Weight: 2},
  776. {Name: "MostRequestedPriority", Weight: 2},
  777. {
  778. Name: "RequestedToCapacityRatioPriority",
  779. Weight: 2,
  780. Argument: &schedulerapi.PriorityArgument{
  781. RequestedToCapacityRatioArguments: &schedulerapi.RequestedToCapacityRatioArguments{
  782. UtilizationShape: []schedulerapi.UtilizationShapePoint{
  783. {Utilization: 0, Score: 0},
  784. {Utilization: 50, Score: 7},
  785. }},
  786. },
  787. },
  788. },
  789. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  790. URLPrefix: "/prefix",
  791. FilterVerb: "filter",
  792. PrioritizeVerb: "prioritize",
  793. Weight: 1,
  794. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  795. EnableHTTPS: true,
  796. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  797. HTTPTimeout: 1,
  798. NodeCacheCapable: true,
  799. ManagedResources: []schedulerapi.ExtenderManagedResource{{Name: v1.ResourceName("example.com/foo"), IgnoredByScheduler: true}},
  800. Ignorable: true,
  801. }},
  802. },
  803. },
  804. // Do not change this JSON after the corresponding release has been tagged.
  805. // A failure indicates backwards compatibility with the specified release was broken.
  806. "1.12": {
  807. JSON: `{
  808. "kind": "Policy",
  809. "apiVersion": "v1",
  810. "predicates": [
  811. {"name": "MatchNodeSelector"},
  812. {"name": "PodFitsResources"},
  813. {"name": "PodFitsHostPorts"},
  814. {"name": "HostName"},
  815. {"name": "NoDiskConflict"},
  816. {"name": "NoVolumeZoneConflict"},
  817. {"name": "PodToleratesNodeTaints"},
  818. {"name": "CheckNodeMemoryPressure"},
  819. {"name": "CheckNodeDiskPressure"},
  820. {"name": "CheckNodePIDPressure"},
  821. {"name": "CheckNodeCondition"},
  822. {"name": "MaxEBSVolumeCount"},
  823. {"name": "MaxGCEPDVolumeCount"},
  824. {"name": "MaxAzureDiskVolumeCount"},
  825. {"name": "MaxCSIVolumeCountPred"},
  826. {"name": "MatchInterPodAffinity"},
  827. {"name": "GeneralPredicates"},
  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. ExpectedPolicy: schedulerapi.Policy{
  868. Predicates: []schedulerapi.PredicatePolicy{
  869. {Name: "MatchNodeSelector"},
  870. {Name: "PodFitsResources"},
  871. {Name: "PodFitsHostPorts"},
  872. {Name: "HostName"},
  873. {Name: "NoDiskConflict"},
  874. {Name: "NoVolumeZoneConflict"},
  875. {Name: "PodToleratesNodeTaints"},
  876. {Name: "CheckNodeMemoryPressure"},
  877. {Name: "CheckNodeDiskPressure"},
  878. {Name: "CheckNodePIDPressure"},
  879. {Name: "CheckNodeCondition"},
  880. {Name: "MaxEBSVolumeCount"},
  881. {Name: "MaxGCEPDVolumeCount"},
  882. {Name: "MaxAzureDiskVolumeCount"},
  883. {Name: "MaxCSIVolumeCountPred"},
  884. {Name: "MatchInterPodAffinity"},
  885. {Name: "GeneralPredicates"},
  886. {Name: "CheckVolumeBinding"},
  887. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  888. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  889. },
  890. Priorities: []schedulerapi.PriorityPolicy{
  891. {Name: "EqualPriority", Weight: 2},
  892. {Name: "ImageLocalityPriority", Weight: 2},
  893. {Name: "LeastRequestedPriority", Weight: 2},
  894. {Name: "BalancedResourceAllocation", Weight: 2},
  895. {Name: "SelectorSpreadPriority", Weight: 2},
  896. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  897. {Name: "NodeAffinityPriority", Weight: 2},
  898. {Name: "TaintTolerationPriority", Weight: 2},
  899. {Name: "InterPodAffinityPriority", Weight: 2},
  900. {Name: "MostRequestedPriority", Weight: 2},
  901. {
  902. Name: "RequestedToCapacityRatioPriority",
  903. Weight: 2,
  904. Argument: &schedulerapi.PriorityArgument{
  905. RequestedToCapacityRatioArguments: &schedulerapi.RequestedToCapacityRatioArguments{
  906. UtilizationShape: []schedulerapi.UtilizationShapePoint{
  907. {Utilization: 0, Score: 0},
  908. {Utilization: 50, Score: 7},
  909. }},
  910. },
  911. },
  912. },
  913. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  914. URLPrefix: "/prefix",
  915. FilterVerb: "filter",
  916. PrioritizeVerb: "prioritize",
  917. Weight: 1,
  918. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  919. EnableHTTPS: true,
  920. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  921. HTTPTimeout: 1,
  922. NodeCacheCapable: true,
  923. ManagedResources: []schedulerapi.ExtenderManagedResource{{Name: v1.ResourceName("example.com/foo"), IgnoredByScheduler: true}},
  924. Ignorable: true,
  925. }},
  926. },
  927. },
  928. "1.14": {
  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": "CheckNodeMemoryPressure"},
  941. {"name": "CheckNodeDiskPressure"},
  942. {"name": "CheckNodePIDPressure"},
  943. {"name": "CheckNodeCondition"},
  944. {"name": "MaxEBSVolumeCount"},
  945. {"name": "MaxGCEPDVolumeCount"},
  946. {"name": "MaxAzureDiskVolumeCount"},
  947. {"name": "MaxCSIVolumeCountPred"},
  948. {"name": "MaxCinderVolumeCount"},
  949. {"name": "MatchInterPodAffinity"},
  950. {"name": "GeneralPredicates"},
  951. {"name": "CheckVolumeBinding"},
  952. {"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
  953. {"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
  954. ],"priorities": [
  955. {"name": "EqualPriority", "weight": 2},
  956. {"name": "ImageLocalityPriority", "weight": 2},
  957. {"name": "LeastRequestedPriority", "weight": 2},
  958. {"name": "BalancedResourceAllocation", "weight": 2},
  959. {"name": "SelectorSpreadPriority", "weight": 2},
  960. {"name": "NodePreferAvoidPodsPriority", "weight": 2},
  961. {"name": "NodeAffinityPriority", "weight": 2},
  962. {"name": "TaintTolerationPriority", "weight": 2},
  963. {"name": "InterPodAffinityPriority", "weight": 2},
  964. {"name": "MostRequestedPriority", "weight": 2},
  965. {
  966. "name": "RequestedToCapacityRatioPriority",
  967. "weight": 2,
  968. "argument": {
  969. "requestedToCapacityRatioArguments": {
  970. "shape": [
  971. {"utilization": 0, "score": 0},
  972. {"utilization": 50, "score": 7}
  973. ]
  974. }
  975. }}
  976. ],"extenders": [{
  977. "urlPrefix": "/prefix",
  978. "filterVerb": "filter",
  979. "prioritizeVerb": "prioritize",
  980. "weight": 1,
  981. "bindVerb": "bind",
  982. "enableHttps": true,
  983. "tlsConfig": {"Insecure":true},
  984. "httpTimeout": 1,
  985. "nodeCacheCapable": true,
  986. "managedResources": [{"name":"example.com/foo","ignoredByScheduler":true}],
  987. "ignorable":true
  988. }]
  989. }`,
  990. ExpectedPolicy: schedulerapi.Policy{
  991. Predicates: []schedulerapi.PredicatePolicy{
  992. {Name: "MatchNodeSelector"},
  993. {Name: "PodFitsResources"},
  994. {Name: "PodFitsHostPorts"},
  995. {Name: "HostName"},
  996. {Name: "NoDiskConflict"},
  997. {Name: "NoVolumeZoneConflict"},
  998. {Name: "PodToleratesNodeTaints"},
  999. {Name: "CheckNodeMemoryPressure"},
  1000. {Name: "CheckNodeDiskPressure"},
  1001. {Name: "CheckNodePIDPressure"},
  1002. {Name: "CheckNodeCondition"},
  1003. {Name: "MaxEBSVolumeCount"},
  1004. {Name: "MaxGCEPDVolumeCount"},
  1005. {Name: "MaxAzureDiskVolumeCount"},
  1006. {Name: "MaxCSIVolumeCountPred"},
  1007. {Name: "MaxCinderVolumeCount"},
  1008. {Name: "MatchInterPodAffinity"},
  1009. {Name: "GeneralPredicates"},
  1010. {Name: "CheckVolumeBinding"},
  1011. {Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
  1012. {Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
  1013. },
  1014. Priorities: []schedulerapi.PriorityPolicy{
  1015. {Name: "EqualPriority", Weight: 2},
  1016. {Name: "ImageLocalityPriority", Weight: 2},
  1017. {Name: "LeastRequestedPriority", Weight: 2},
  1018. {Name: "BalancedResourceAllocation", Weight: 2},
  1019. {Name: "SelectorSpreadPriority", Weight: 2},
  1020. {Name: "NodePreferAvoidPodsPriority", Weight: 2},
  1021. {Name: "NodeAffinityPriority", Weight: 2},
  1022. {Name: "TaintTolerationPriority", Weight: 2},
  1023. {Name: "InterPodAffinityPriority", Weight: 2},
  1024. {Name: "MostRequestedPriority", Weight: 2},
  1025. {
  1026. Name: "RequestedToCapacityRatioPriority",
  1027. Weight: 2,
  1028. Argument: &schedulerapi.PriorityArgument{
  1029. RequestedToCapacityRatioArguments: &schedulerapi.RequestedToCapacityRatioArguments{
  1030. UtilizationShape: []schedulerapi.UtilizationShapePoint{
  1031. {Utilization: 0, Score: 0},
  1032. {Utilization: 50, Score: 7},
  1033. }},
  1034. },
  1035. },
  1036. },
  1037. ExtenderConfigs: []schedulerapi.ExtenderConfig{{
  1038. URLPrefix: "/prefix",
  1039. FilterVerb: "filter",
  1040. PrioritizeVerb: "prioritize",
  1041. Weight: 1,
  1042. BindVerb: "bind", // 1.11 restored case-sensitivity, but allowed either "BindVerb" or "bindVerb"
  1043. EnableHTTPS: true,
  1044. TLSConfig: &schedulerapi.ExtenderTLSConfig{Insecure: true},
  1045. HTTPTimeout: 1,
  1046. NodeCacheCapable: true,
  1047. ManagedResources: []schedulerapi.ExtenderManagedResource{{Name: v1.ResourceName("example.com/foo"), IgnoredByScheduler: true}},
  1048. Ignorable: true,
  1049. }},
  1050. },
  1051. },
  1052. }
  1053. registeredPredicates := sets.NewString(factory.ListRegisteredFitPredicates()...)
  1054. registeredPriorities := sets.NewString(factory.ListRegisteredPriorityFunctions()...)
  1055. seenPredicates := sets.NewString()
  1056. seenPriorities := sets.NewString()
  1057. for v, tc := range schedulerFiles {
  1058. fmt.Printf("%s: Testing scheduler config\n", v)
  1059. policy := schedulerapi.Policy{}
  1060. if err := runtime.DecodeInto(latestschedulerapi.Codec, []byte(tc.JSON), &policy); err != nil {
  1061. t.Errorf("%s: Error decoding: %v", v, err)
  1062. continue
  1063. }
  1064. for _, predicate := range policy.Predicates {
  1065. seenPredicates.Insert(predicate.Name)
  1066. }
  1067. for _, priority := range policy.Priorities {
  1068. seenPriorities.Insert(priority.Name)
  1069. }
  1070. if !reflect.DeepEqual(policy, tc.ExpectedPolicy) {
  1071. t.Errorf("%s: Expected:\n\t%#v\nGot:\n\t%#v", v, tc.ExpectedPolicy, policy)
  1072. }
  1073. handler := utiltesting.FakeHandler{
  1074. StatusCode: 500,
  1075. ResponseBody: "",
  1076. T: t,
  1077. }
  1078. server := httptest.NewServer(&handler)
  1079. defer server.Close()
  1080. client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
  1081. informerFactory := informers.NewSharedInformerFactory(client, 0)
  1082. if _, err := factory.NewConfigFactory(&factory.ConfigFactoryArgs{
  1083. SchedulerName: "some-scheduler-name",
  1084. Client: client,
  1085. NodeInformer: informerFactory.Core().V1().Nodes(),
  1086. PodInformer: informerFactory.Core().V1().Pods(),
  1087. PvInformer: informerFactory.Core().V1().PersistentVolumes(),
  1088. PvcInformer: informerFactory.Core().V1().PersistentVolumeClaims(),
  1089. ReplicationControllerInformer: informerFactory.Core().V1().ReplicationControllers(),
  1090. ReplicaSetInformer: informerFactory.Apps().V1().ReplicaSets(),
  1091. StatefulSetInformer: informerFactory.Apps().V1().StatefulSets(),
  1092. ServiceInformer: informerFactory.Core().V1().Services(),
  1093. PdbInformer: informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
  1094. StorageClassInformer: informerFactory.Storage().V1().StorageClasses(),
  1095. HardPodAffinitySymmetricWeight: v1.DefaultHardPodAffinitySymmetricWeight,
  1096. DisablePreemption: false,
  1097. PercentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
  1098. }).CreateFromConfig(policy); err != nil {
  1099. t.Errorf("%s: Error constructing: %v", v, err)
  1100. continue
  1101. }
  1102. }
  1103. if !seenPredicates.HasAll(registeredPredicates.List()...) {
  1104. t.Errorf("Registered predicates are missing from compatibility test (add to test stanza for version currently in development): %#v", registeredPredicates.Difference(seenPredicates).List())
  1105. }
  1106. if !seenPriorities.HasAll(registeredPriorities.List()...) {
  1107. t.Errorf("Registered priorities are missing from compatibility test (add to test stanza for version currently in development): %#v", registeredPriorities.Difference(seenPriorities).List())
  1108. }
  1109. }