Do not compare StartTime for unschedulable pods

Using standard MostImportantPod function for pods which do not have
Status.StartTime set result in Error log message which kills
scalability.
This commit is contained in:
Łukasz Osipiuk 2020-01-27 18:30:44 +01:00
parent 36fe4949c6
commit f419498b07
1 changed files with 10 additions and 2 deletions

View File

@ -31,7 +31,7 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/scheduler/util"
"k8s.io/kubernetes/pkg/api/v1/pod"
)
type filterOutSchedulablePodListProcessor struct{}
@ -108,7 +108,7 @@ func filterOutSchedulableByPacking(unschedulableCandidates []*apiv1.Pod, nodes [
nodeNameToNodeInfo := schedulerutil.CreateNodeNameToInfoMap(nonExpendableScheduled, nodes)
sort.Slice(unschedulableCandidates, func(i, j int) bool {
return util.MoreImportantPod(unschedulableCandidates[i], unschedulableCandidates[j])
return moreImportantPod(unschedulableCandidates[i], unschedulableCandidates[j])
})
for _, pod := range unschedulableCandidates {
@ -133,6 +133,14 @@ func filterOutSchedulableByPacking(unschedulableCandidates []*apiv1.Pod, nodes [
return unschedulablePods
}
func moreImportantPod(pod1, pod2 *apiv1.Pod) bool {
// based on schedulers MoreImportantPod but does not compare Pod.Status.StartTime which does not make sense
// for unschedulable pods
p1 := pod.GetPodPriority(pod1)
p2 := pod.GetPodPriority(pod2)
return p1 > p2
}
// filterOutSchedulableSimple checks whether pods from <unschedulableCandidates> marked as unschedulable
// by Scheduler actually can't be scheduled on any node and filter out the ones that can.
// It takes into account pods that are bound to node and will be scheduled after lower priority pod preemption.