Solved the test problem and added update comment

This commit is contained in:
boenn
2021-07-09 11:56:43 +08:00
parent d6f2473d08
commit 1980b18c45
2 changed files with 15 additions and 7 deletions

View File

@@ -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 {