@@ -501,16 +501,6 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
501
501
// This allows us to keep scheduling without waiting on binding to occur.
502
502
assumedPodInfo := podInfo .DeepCopy ()
503
503
assumedPod := assumedPodInfo .Pod
504
-
505
- // Run the Reserve method of reserve plugins.
506
- if sts := prof .RunReservePluginsReserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost ); ! sts .IsSuccess () {
507
- sched .recordSchedulingFailure (prof , assumedPodInfo , sts .AsError (), SchedulerError , "" )
508
- metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
509
- // trigger un-reserve to clean up state associated with the reserved Pod
510
- prof .RunReservePluginsUnreserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
511
- return
512
- }
513
-
514
504
// assume modifies `assumedPod` by setting NodeName=scheduleResult.SuggestedHost
515
505
err = sched .assume (assumedPod , scheduleResult .SuggestedHost )
516
506
if err != nil {
@@ -521,7 +511,14 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
521
511
// (otherwise this would cause an infinite loop).
522
512
sched .recordSchedulingFailure (prof , assumedPodInfo , err , SchedulerError , "" )
523
513
metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
524
- // trigger un-reserve plugins to clean up state associated with the reserved Pod
514
+ return
515
+ }
516
+
517
+ // Run the Reserve method of reserve plugins.
518
+ if sts := prof .RunReservePluginsReserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost ); ! sts .IsSuccess () {
519
+ sched .recordSchedulingFailure (prof , assumedPodInfo , sts .AsError (), SchedulerError , "" )
520
+ metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
521
+ // trigger un-reserve to clean up state associated with the reserved Pod
525
522
prof .RunReservePluginsUnreserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
526
523
return
527
524
}
@@ -537,11 +534,11 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
537
534
metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
538
535
reason = SchedulerError
539
536
}
537
+ // One of the plugins returned status different than success or wait.
538
+ prof .RunReservePluginsUnreserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
540
539
if forgetErr := sched .Cache ().ForgetPod (assumedPod ); forgetErr != nil {
541
540
klog .Errorf ("scheduler cache ForgetPod failed: %v" , forgetErr )
542
541
}
543
- // One of the plugins returned status different than success or wait.
544
- prof .RunReservePluginsUnreserve (schedulingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
545
542
sched .recordSchedulingFailure (prof , assumedPodInfo , runPermitStatus .AsError (), reason , "" )
546
543
return
547
544
}
@@ -563,27 +560,25 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
563
560
metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
564
561
reason = SchedulerError
565
562
}
563
+ // trigger un-reserve plugins to clean up state associated with the reserved Pod
564
+ prof .RunReservePluginsUnreserve (bindingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
566
565
if forgetErr := sched .Cache ().ForgetPod (assumedPod ); forgetErr != nil {
567
566
klog .Errorf ("scheduler cache ForgetPod failed: %v" , forgetErr )
568
567
}
569
- // trigger un-reserve plugins to clean up state associated with the reserved Pod
570
- prof .RunReservePluginsUnreserve (bindingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
571
568
sched .recordSchedulingFailure (prof , assumedPodInfo , waitOnPermitStatus .AsError (), reason , "" )
572
569
return
573
570
}
574
571
575
572
// Run "prebind" plugins.
576
573
preBindStatus := prof .RunPreBindPlugins (bindingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
577
574
if ! preBindStatus .IsSuccess () {
578
- var reason string
579
575
metrics .PodScheduleError (prof .Name , metrics .SinceInSeconds (start ))
580
- reason = SchedulerError
576
+ // trigger un-reserve plugins to clean up state associated with the reserved Pod
577
+ prof .RunReservePluginsUnreserve (bindingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
581
578
if forgetErr := sched .Cache ().ForgetPod (assumedPod ); forgetErr != nil {
582
579
klog .Errorf ("scheduler cache ForgetPod failed: %v" , forgetErr )
583
580
}
584
- // trigger un-reserve plugins to clean up state associated with the reserved Pod
585
- prof .RunReservePluginsUnreserve (bindingCycleCtx , state , assumedPod , scheduleResult .SuggestedHost )
586
- sched .recordSchedulingFailure (prof , assumedPodInfo , preBindStatus .AsError (), reason , "" )
581
+ sched .recordSchedulingFailure (prof , assumedPodInfo , preBindStatus .AsError (), SchedulerError , "" )
587
582
return
588
583
}
589
584
0 commit comments