mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Solved the test problem and added update comment
This commit is contained in:
parent
d6f2473d08
commit
1980b18c45
@ -700,14 +700,17 @@ func (npm *nominator) AddNominatedPod(pi *framework.PodInfo, nodeName string) {
|
||||
npm.Unlock()
|
||||
}
|
||||
|
||||
// NominatedPodsForNode returns pods that are nominated to run on the given node,
|
||||
// NominatedPodsForNode returns a copy of pods that are nominated to run on the given node,
|
||||
// but they are waiting for other pods to be removed from the node.
|
||||
func (npm *nominator) NominatedPodsForNode(nodeName string) []*framework.PodInfo {
|
||||
npm.RLock()
|
||||
defer npm.RUnlock()
|
||||
// TODO: we may need to return a copy of []*Pods to avoid modification
|
||||
// on the caller side.
|
||||
return npm.nominatedPods[nodeName]
|
||||
// Make a copy of the nominated Pods so the caller can mutate safely.
|
||||
pods := make([]*framework.PodInfo, len(npm.nominatedPods[nodeName]))
|
||||
for i := 0; i < len(pods); i++ {
|
||||
pods[i] = npm.nominatedPods[nodeName][i].DeepCopy()
|
||||
}
|
||||
return pods
|
||||
}
|
||||
|
||||
func (p *PriorityQueue) podsCompareBackoffCompleted(podInfo1, podInfo2 interface{}) bool {
|
||||
|
@ -650,10 +650,15 @@ func TestPriorityQueue_NominatedPodsForNode(t *testing.T) {
|
||||
t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPodInfo.Pod.Name, p.Pod.Name)
|
||||
}
|
||||
expectedList := []*framework.PodInfo{medPriorityPodInfo, unschedulablePodInfo}
|
||||
if !reflect.DeepEqual(expectedList, q.NominatedPodsForNode("node1")) {
|
||||
t.Error("Unexpected list of nominated Pods for node.")
|
||||
podInfos := q.NominatedPodsForNode("node1")
|
||||
if diff := cmp.Diff(expectedList, podInfos); diff != "" {
|
||||
t.Errorf("Unexpected list of nominated Pods for node: (-want, +got):\n%s", diff)
|
||||
}
|
||||
if q.NominatedPodsForNode("node2") != nil {
|
||||
podInfos[0].Pod.Name = "not mpp"
|
||||
if diff := cmp.Diff(podInfos, q.NominatedPodsForNode("node1")); diff == "" {
|
||||
t.Error("Expected list of nominated Pods for node2 is different from podInfos")
|
||||
}
|
||||
if len(q.NominatedPodsForNode("node2")) != 0 {
|
||||
t.Error("Expected list of nominated Pods for node2 to be empty.")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user