EvenPodsSpread: minor enhancement on printing out priority score

This commit is contained in:
Wei Huang 2019-05-14 14:01:53 -07:00
parent 821446ed70
commit 3638fd5353
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005

View File

@ -177,6 +177,15 @@ func CalculateEvenPodsSpreadPriority(pod *v1.Pod, nodeNameToInfo map[string]*sch
for i := range nodes {
node := nodes[i]
result[i].Host = node.Name
// debugging purpose: print the value for each node
// score must be pointer here, otherwise it's always 0
if klog.V(10) {
defer func(score *int, nodeName string) {
klog.Infof("%v -> %v: EvenPodsSpreadPriority, Score: (%d)", pod.Name, nodeName, *score)
}(&result[i].Score, node.Name)
}
if t.counts[node.Name] == nil {
result[i].Score = 0
continue
@ -189,9 +198,6 @@ func CalculateEvenPodsSpreadPriority(pod *v1.Pod, nodeNameToInfo map[string]*sch
// need to reverse b/c the more matching pods it has, the less qualified it is
// result[i].Score = schedulerapi.MaxPriority - int(fScore)
result[i].Score = int(fScore)
if klog.V(10) {
klog.Infof("%v -> %v: EvenPodsSpreadPriority, Score: (%d)", pod.Name, node.Name, int(fScore))
}
}
return result, nil