mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #75703 from tedyu/master
Simplify the loop for latest start time in pickOneNodeForPreemption
This commit is contained in:
commit
1ac4cc7980
@ -916,8 +916,8 @@ func pickOneNodeForPreemption(nodesToVictims map[*v1.Node]*schedulerapi.Victims)
|
|||||||
klog.Errorf("earliestStartTime is nil for node %s. Should not reach here.", minNodes2[0])
|
klog.Errorf("earliestStartTime is nil for node %s. Should not reach here.", minNodes2[0])
|
||||||
return minNodes2[0]
|
return minNodes2[0]
|
||||||
}
|
}
|
||||||
lenNodes1 = 0
|
nodeToReturn := minNodes2[0]
|
||||||
for i := 0; i < lenNodes2; i++ {
|
for i := 1; i < lenNodes2; i++ {
|
||||||
node := minNodes2[i]
|
node := minNodes2[i]
|
||||||
// Get earliest start time of all pods on the current node.
|
// Get earliest start time of all pods on the current node.
|
||||||
earliestStartTimeOnNode := util.GetEarliestPodStartTime(nodesToVictims[node])
|
earliestStartTimeOnNode := util.GetEarliestPodStartTime(nodesToVictims[node])
|
||||||
@ -927,22 +927,11 @@ func pickOneNodeForPreemption(nodesToVictims map[*v1.Node]*schedulerapi.Victims)
|
|||||||
}
|
}
|
||||||
if earliestStartTimeOnNode.After(latestStartTime.Time) {
|
if earliestStartTimeOnNode.After(latestStartTime.Time) {
|
||||||
latestStartTime = earliestStartTimeOnNode
|
latestStartTime = earliestStartTimeOnNode
|
||||||
lenNodes1 = 0
|
nodeToReturn = node
|
||||||
}
|
|
||||||
if earliestStartTimeOnNode.Equal(latestStartTime) {
|
|
||||||
minNodes1[lenNodes1] = node
|
|
||||||
lenNodes1++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, even if there are more than one node with the same score,
|
return nodeToReturn
|
||||||
// return the first one.
|
|
||||||
if lenNodes1 > 0 {
|
|
||||||
return minNodes1[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
klog.Errorf("Error in logic of node scoring for preemption. We should never reach here!")
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// selectNodesForPreemption finds all the nodes with possible victims for
|
// selectNodesForPreemption finds all the nodes with possible victims for
|
||||||
|
Loading…
Reference in New Issue
Block a user