Merge pull request #80846 from tedyu/apply-wght-early

Return early in ApplyScoreWeights if there are no scores
This commit is contained in:
Kubernetes Prow Robot 2019-08-01 13:38:54 -07:00 committed by GitHub
commit a8d20287bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -203,6 +203,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node
for _, existingPod := range nodeInfo.Pods() {
if err := processPod(existingPod); err != nil {
errCh.SendErrorWithCancel(err, cancel)
return
}
}
} else {
@ -211,6 +212,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node
for _, existingPod := range nodeInfo.PodsWithAffinity() {
if err := processPod(existingPod); err != nil {
errCh.SendErrorWithCancel(err, cancel)
return
}
}
}

View File

@ -357,11 +357,13 @@ func (f *framework) RunNormalizeScorePlugins(pc *PluginContext, pod *v1.Pod, sco
if !ok {
err := fmt.Errorf("normalize score plugin %v has no corresponding scores in the PluginToNodeScoreMap", pl.Name())
errCh.SendErrorWithCancel(err, cancel)
return
}
status := pl.NormalizeScore(pc, pod, nodeScoreList)
if !status.IsSuccess() {
err := fmt.Errorf("normalize score plugin %v failed with error %v", pl.Name(), status.Message())
errCh.SendErrorWithCancel(err, cancel)
return
}
})
@ -387,6 +389,7 @@ func (f *framework) ApplyScoreWeights(pc *PluginContext, pod *v1.Pod, scores Plu
if !ok {
err := fmt.Errorf("score plugin %v has no corresponding scores in the PluginToNodeScoreMap", pl.Name())
errCh.SendErrorWithCancel(err, cancel)
return
}
for i := range nodeScoreList {
nodeScoreList[i] = nodeScoreList[i] * weight