Skip to content

Commit a792391

Browse files
committed
adapt to SDK changes in k8s 1.27
1 parent 778179c commit a792391

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed

cmd/scheduler/main_test.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ profiles:
497497
registryOptions: []app.Option{app.WithPlugin(podstate.Name, podstate.New)},
498498
wantPlugins: map[string]*config.Plugins{
499499
"default-scheduler": {
500+
PreEnqueue: defaults.PluginsV1beta2.PreEnqueue,
500501
QueueSort: defaults.PluginsV1beta2.QueueSort,
501502
Bind: defaults.PluginsV1beta2.Bind,
502503
PostFilter: defaults.PluginsV1beta2.PostFilter,
@@ -512,6 +513,7 @@ profiles:
512513
registryOptions: []app.Option{app.WithPlugin(qos.Name, qos.New)},
513514
wantPlugins: map[string]*config.Plugins{
514515
"default-scheduler": {
516+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
515517
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: qos.Name}}},
516518
Bind: defaults.ExpandedPluginsV1beta3.Bind,
517519
PostFilter: defaults.ExpandedPluginsV1beta3.PostFilter,
@@ -527,6 +529,7 @@ profiles:
527529
wantPlugins: map[string]*config.Plugins{
528530
"default-scheduler": {
529531
MultiPoint: defaults.ExpandedPluginsV1.MultiPoint,
532+
PreEnqueue: defaults.ExpandedPluginsV1.PreEnqueue,
530533
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: coscheduling.Name}}},
531534
Bind: defaults.ExpandedPluginsV1.Bind,
532535
PreFilter: config.PluginSet{
@@ -551,6 +554,7 @@ profiles:
551554
registryOptions: []app.Option{app.WithPlugin(noderesources.AllocatableName, noderesources.NewAllocatable)},
552555
wantPlugins: map[string]*config.Plugins{
553556
"default-scheduler": {
557+
PreEnqueue: defaults.ExpandedPluginsV1.PreEnqueue,
554558
QueueSort: defaults.ExpandedPluginsV1.QueueSort,
555559
Bind: defaults.ExpandedPluginsV1.Bind,
556560
PreFilter: defaults.ExpandedPluginsV1.PreFilter,
@@ -569,8 +573,9 @@ profiles:
569573
registryOptions: []app.Option{app.WithPlugin(capacityscheduling.Name, capacityscheduling.New)},
570574
wantPlugins: map[string]*config.Plugins{
571575
"default-scheduler": {
572-
QueueSort: defaults.PluginsV1beta2.QueueSort,
573-
Bind: defaults.PluginsV1beta2.Bind,
576+
PreEnqueue: defaults.PluginsV1beta2.PreEnqueue,
577+
QueueSort: defaults.PluginsV1beta2.QueueSort,
578+
Bind: defaults.PluginsV1beta2.Bind,
574579
PreFilter: config.PluginSet{
575580
Enabled: append(defaults.PluginsV1beta2.PreFilter.Enabled, config.Plugin{Name: capacityscheduling.Name}),
576581
},
@@ -591,8 +596,9 @@ profiles:
591596
registryOptions: []app.Option{app.WithPlugin(capacityscheduling.Name, capacityscheduling.New)},
592597
wantPlugins: map[string]*config.Plugins{
593598
"default-scheduler": {
594-
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
595-
Bind: defaults.ExpandedPluginsV1beta3.Bind,
599+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
600+
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
601+
Bind: defaults.ExpandedPluginsV1beta3.Bind,
596602
PreFilter: config.PluginSet{
597603
Enabled: append(defaults.ExpandedPluginsV1beta3.PreFilter.Enabled, config.Plugin{Name: capacityscheduling.Name}),
598604
},
@@ -613,6 +619,7 @@ profiles:
613619
registryOptions: []app.Option{app.WithPlugin(targetloadpacking.Name, targetloadpacking.New)},
614620
wantPlugins: map[string]*config.Plugins{
615621
"default-scheduler": {
622+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
616623
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
617624
Bind: defaults.ExpandedPluginsV1beta3.Bind,
618625
PreFilter: defaults.ExpandedPluginsV1beta3.PreFilter,
@@ -631,6 +638,7 @@ profiles:
631638
registryOptions: []app.Option{app.WithPlugin(targetloadpacking.Name, targetloadpacking.New)},
632639
wantPlugins: map[string]*config.Plugins{
633640
"default-scheduler": {
641+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
634642
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
635643
Bind: defaults.ExpandedPluginsV1beta3.Bind,
636644
PreFilter: defaults.ExpandedPluginsV1beta3.PreFilter,
@@ -649,6 +657,7 @@ profiles:
649657
registryOptions: []app.Option{app.WithPlugin(loadvariationriskbalancing.Name, loadvariationriskbalancing.New)},
650658
wantPlugins: map[string]*config.Plugins{
651659
"default-scheduler": {
660+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
652661
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
653662
Bind: defaults.ExpandedPluginsV1beta3.Bind,
654663
PreFilter: defaults.ExpandedPluginsV1beta3.PreFilter,
@@ -667,6 +676,7 @@ profiles:
667676
registryOptions: []app.Option{app.WithPlugin(lowriskovercommitment.Name, lowriskovercommitment.New)},
668677
wantPlugins: map[string]*config.Plugins{
669678
"default-scheduler": {
679+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
670680
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
671681
Bind: defaults.ExpandedPluginsV1beta3.Bind,
672682
PreFilter: defaults.ExpandedPluginsV1beta3.PreFilter,
@@ -685,6 +695,7 @@ profiles:
685695
registryOptions: []app.Option{app.WithPlugin(noderesourcetopology.Name, noderesourcetopology.New)},
686696
wantPlugins: map[string]*config.Plugins{
687697
"default-scheduler": {
698+
PreEnqueue: defaults.ExpandedPluginsV1.PreEnqueue,
688699
QueueSort: defaults.ExpandedPluginsV1.QueueSort,
689700
Bind: defaults.ExpandedPluginsV1.Bind,
690701
PreFilter: defaults.ExpandedPluginsV1.PreFilter,
@@ -703,6 +714,7 @@ profiles:
703714
registryOptions: []app.Option{app.WithPlugin(topologicalsort.Name, topologicalsort.New)},
704715
wantPlugins: map[string]*config.Plugins{
705716
"default-scheduler": {
717+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
706718
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: topologicalsort.Name}}},
707719
Bind: defaults.ExpandedPluginsV1beta3.Bind,
708720
PostFilter: defaults.ExpandedPluginsV1beta3.PostFilter,
@@ -717,8 +729,9 @@ profiles:
717729
registryOptions: []app.Option{app.WithPlugin(networkoverhead.Name, networkoverhead.New)},
718730
wantPlugins: map[string]*config.Plugins{
719731
"default-scheduler": {
720-
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
721-
Bind: defaults.ExpandedPluginsV1beta3.Bind,
732+
PreEnqueue: defaults.ExpandedPluginsV1beta3.PreEnqueue,
733+
QueueSort: defaults.ExpandedPluginsV1beta3.QueueSort,
734+
Bind: defaults.ExpandedPluginsV1beta3.Bind,
722735
PreFilter: config.PluginSet{
723736
Enabled: append(defaults.ExpandedPluginsV1beta3.PreFilter.Enabled, config.Plugin{Name: networkoverhead.Name}),
724737
},

pkg/coscheduling/coscheduling.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ func (cs *Coscheduling) Less(podInfo1, podInfo2 *framework.QueuedPodInfo) bool {
123123
if prio1 != prio2 {
124124
return prio1 > prio2
125125
}
126-
creationTime1 := cs.pgMgr.GetCreationTimestamp(podInfo1.Pod, podInfo1.InitialAttemptTimestamp)
127-
creationTime2 := cs.pgMgr.GetCreationTimestamp(podInfo2.Pod, podInfo2.InitialAttemptTimestamp)
126+
creationTime1 := cs.pgMgr.GetCreationTimestamp(podInfo1.Pod, *podInfo1.InitialAttemptTimestamp)
127+
creationTime2 := cs.pgMgr.GetCreationTimestamp(podInfo2.Pod, *podInfo2.InitialAttemptTimestamp)
128128
if creationTime1.Equal(creationTime2) {
129129
return core.GetNamespacedName(podInfo1.Pod) < core.GetNamespacedName(podInfo2.Pod)
130130
}

pkg/coscheduling/coscheduling_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,23 @@ func TestLess(t *testing.T) {
217217
name: "equal priority. p1 is added to schedulingQ earlier than p2",
218218
p1: &framework.QueuedPodInfo{
219219
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Obj()),
220-
InitialAttemptTimestamp: times[0],
220+
InitialAttemptTimestamp: &times[0],
221221
},
222222
p2: &framework.QueuedPodInfo{
223223
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Obj()),
224-
InitialAttemptTimestamp: times[1],
224+
InitialAttemptTimestamp: &times[1],
225225
},
226226
expected: true, // p1 should be ahead of p2 in the queue
227227
},
228228
{
229229
name: "equal priority. p2 is added to schedulingQ earlier than p1",
230230
p1: &framework.QueuedPodInfo{
231231
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Obj()),
232-
InitialAttemptTimestamp: times[1],
232+
InitialAttemptTimestamp: &times[1],
233233
},
234234
p2: &framework.QueuedPodInfo{
235235
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Obj()),
236-
InitialAttemptTimestamp: times[0],
236+
InitialAttemptTimestamp: &times[0],
237237
},
238238
expected: false, // p2 should be ahead of p1 in the queue
239239
},
@@ -261,23 +261,23 @@ func TestLess(t *testing.T) {
261261
name: "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup3",
262262
p1: &framework.QueuedPodInfo{
263263
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()),
264-
InitialAttemptTimestamp: times[0],
264+
InitialAttemptTimestamp: &times[0],
265265
},
266266
p2: &framework.QueuedPodInfo{
267267
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Obj()),
268-
InitialAttemptTimestamp: times[1],
268+
InitialAttemptTimestamp: &times[1],
269269
},
270270
expected: true, // p1 should be ahead of p2 in the queue
271271
},
272272
{
273273
name: "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup3",
274274
p1: &framework.QueuedPodInfo{
275275
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()),
276-
InitialAttemptTimestamp: times[1],
276+
InitialAttemptTimestamp: &times[1],
277277
},
278278
p2: &framework.QueuedPodInfo{
279279
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Obj()),
280-
InitialAttemptTimestamp: times[0],
280+
InitialAttemptTimestamp: &times[0],
281281
},
282282
expected: false, // p2 should be ahead of p1 in the queue
283283
},
@@ -306,47 +306,47 @@ func TestLess(t *testing.T) {
306306
name: "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup1 and p2 belongs to podGroup2",
307307
p1: &framework.QueuedPodInfo{
308308
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()),
309-
InitialAttemptTimestamp: times[0],
309+
InitialAttemptTimestamp: &times[0],
310310
},
311311
p2: &framework.QueuedPodInfo{
312312
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()),
313-
InitialAttemptTimestamp: times[1],
313+
InitialAttemptTimestamp: &times[1],
314314
},
315315
expected: true, // p1 should be ahead of p2 in the queue
316316
},
317317
{
318318
name: "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup4 and p2 belongs to podGroup3",
319319
p1: &framework.QueuedPodInfo{
320320
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg4").Obj()),
321-
InitialAttemptTimestamp: times[1],
321+
InitialAttemptTimestamp: &times[1],
322322
},
323323
p2: &framework.QueuedPodInfo{
324324
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()),
325-
InitialAttemptTimestamp: times[0],
325+
InitialAttemptTimestamp: &times[0],
326326
},
327327
expected: false, // p2 should be ahead of p1 in the queue
328328
},
329329
{
330330
name: "equal priority and creation time, p1 belongs to podGroup1 and p2 belongs to podGroup2",
331331
p1: &framework.QueuedPodInfo{
332332
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()),
333-
InitialAttemptTimestamp: times[0],
333+
InitialAttemptTimestamp: &times[0],
334334
},
335335
p2: &framework.QueuedPodInfo{
336336
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()),
337-
InitialAttemptTimestamp: times[0],
337+
InitialAttemptTimestamp: &times[0],
338338
},
339339
expected: true, // p1 should be ahead of p2 in the queue
340340
},
341341
{
342342
name: "equal priority and creation time, p2 belong to podGroup2",
343343
p1: &framework.QueuedPodInfo{
344344
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Obj()),
345-
InitialAttemptTimestamp: times[0],
345+
InitialAttemptTimestamp: &times[0],
346346
},
347347
p2: &framework.QueuedPodInfo{
348348
PodInfo: testutil.MustNewPodInfo(t, st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()),
349-
InitialAttemptTimestamp: times[0],
349+
InitialAttemptTimestamp: &times[0],
350350
},
351351
expected: true, // p1 should be ahead of p2 in the queue
352352
},

pkg/noderesources/resource_allocation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ func calculatePodResourceRequest(pod *v1.Pod, resource v1.ResourceName) int64 {
105105
var podRequest int64
106106
for i := range pod.Spec.Containers {
107107
container := &pod.Spec.Containers[i]
108-
value := schedutil.GetRequestForResource(resource, &container.Resources.Requests, true)
109-
podRequest += value
108+
qty := schedutil.GetRequestForResource(resource, &container.Resources.Requests, true)
109+
podRequest += qty.Value()
110110
}
111111

112112
for i := range pod.Spec.InitContainers {
113113
initContainer := &pod.Spec.InitContainers[i]
114-
value := schedutil.GetRequestForResource(resource, &initContainer.Resources.Requests, true)
115-
if podRequest < value {
114+
qty := schedutil.GetRequestForResource(resource, &initContainer.Resources.Requests, true)
115+
if value := qty.Value(); podRequest < value {
116116
podRequest = value
117117
}
118118
}

pkg/trimaran/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (p *PodAssignEventHandler) AddToHandle(handle framework.Handle) {
9292
)
9393
}
9494

95-
func (p *PodAssignEventHandler) OnAdd(obj interface{}) {
95+
func (p *PodAssignEventHandler) OnAdd(obj interface{}, _ bool) {
9696
pod := obj.(*v1.Pod)
9797
p.updateCache(pod)
9898
}

0 commit comments

Comments
 (0)