Change:
<!-- Please only use this template for submitting enhancement requests --What would you like to be : When selecting victims on node in (), take pod's into account. When two pod's Priority is equal, preempt pod whose is later first. Why is this needed: If a pod's has been running for a longer time, it might finish earlier, or it might have done more things. It might make more sense to preempt them later, e.g. a user submitted a job A at time 9:00 am, then he submitted a job B at time 10:00 am, he might expect that scheduler preempts pods for job B first. <!-- DO NOT EDIT BELOW THIS LINE --/kind feature
/sig scheduling /assign cc
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/close
Closing this issue. <detailsIn response to : /close Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/reopen
Reopened this issue. <detailsIn response to : /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
PR implements this feature. We are currently in code freeze for 1.14. The feature will be in 1.15.
Thanks for it. It is similar with a little difference, the PR aims to select a node, and this issue aims to pick a pod whose StartTime is latter after the node has been selected.
I just sent a PR for it. PTAL :)

Discussion:
// and get cached node info by given node name. nodeInfoCopy := f.cachedNodeNameToInfo[node.GetName()].Clone() <del> potentialVictims := util.SortableList{CompFunc: util.HigherPriorityPod} </del> <ins> potentialVictims := util.SortableList{CompFunc: util.MoreImportantPod} </ins> removePod := func(rp *v1.Pod) { nodeInfoCopy.RemovePod(rp)

if nodeInfo == nil { return nil, 0, false } <del> potentialVictims := util.SortableList{CompFunc: util.HigherPriorityPod} </del> <ins> potentialVictims := util.SortableList{CompFunc: util.MoreImportantPod} </ins> nodeInfoCopy := nodeInfo.Clone() removePod := func(rp *v1.Pod) {

expected: map[string]map[string]bool{"machine1": {"b": true, "c": true}}, }, { <ins> name:       "mixed priority pods are preempted, pick later StartTime one when priorities are equal", predicates: map[string]algorithmpredicates.FitPredicate{"matches": algorithmpredicates.PodFitsResources}, nodes:      []string{"machine1", "machine2"}, pod:        &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "machine1", UID: types.UID("machine1")}, Spec: v1.PodSpec{Containers: largeContainers, Priority: &highPriority}}, pods: []*v1.Pod{ {ObjectMeta: metav1.ObjectMeta{Name: "a", UID: types.UID("a")}, Spec: v1.PodSpec{Containers: smallContainers, Priority: &lowPriority, NodeName: "machine1"}, Status: v1.PodStatus{StartTime: &startTime20190107}}, {ObjectMeta: metav1.ObjectMeta{Name: "b", UID: types.UID("b")}, Spec: v1.PodSpec{Containers: smallContainers, Priority: &lowPriority, NodeName: "machine1"}, Status: v1.PodStatus{StartTime: &startTime20190106}}, {ObjectMeta: metav1.ObjectMeta{Name: "c", UID: types.UID("c")}, Spec: v1.PodSpec{Containers: mediumContainers, Priority: &midPriority, NodeName: "machine1"}, Status: v1.PodStatus{StartTime: &startTime20190105}}, {ObjectMeta: metav1.ObjectMeta{Name: "d", UID: types.UID("d")}, Spec: v1.PodSpec{Containers: smallContainers, Priority: &highPriority, NodeName: "machine1"}, Status: v1.PodStatus{StartTime: &startTime20190104}}, {ObjectMeta: metav1.ObjectMeta{Name: "e", UID: types.UID("e")}, Spec: v1.PodSpec{Containers: largeContainers, Priority: &highPriority, NodeName: "machine2"}, Status: v1.PodStatus{StartTime: &startTime20190103}}}, expected: map[string]map[string]bool{"machine1": {"a": true, "c": true}}, }, { </ins> name:       "pod with anti-affinity is preempted", predicates: map[string]algorithmpredicates.FitPredicate{"matches": algorithmpredicates.PodFitsResources}, nodes:      []string{"machine1", "machine2"},

sort.Sort(l) } <del> // HigherPriorityPod return true when priority of the first pod is higher than // the second one. It takes arguments of the type "interface{}" to be used with // SortableList, but expects those arguments to be *v1.Pod. func HigherPriorityPod(pod1, pod2 interface{}) bool { return GetPodPriority(pod1.(*v1.Pod)) > GetPodPriority(pod2.(*v1.Pod)) </del> <ins> // MoreImportantPod return true when priority of the first pod is higher than // the second one. If two pods' priorities are equal, compare their StartTime. // It takes arguments of the type "interface{}" to be used with SortableList, // but expects those arguments to be *v1.Pod. func MoreImportantPod(pod1, pod2 interface{}) bool { p1 := GetPodPriority(pod1.(*v1.Pod)) p2 := GetPodPriority(pod2.(*v1.Pod)) if p1 != p2 { return p1 > p2 } return GetPodStartTime(pod1.(*v1.Pod)).Before(GetPodStartTime(pod2.(*v1.Pod))) </ins> }