From 03cfd30ee21bb5e70008b81299144b95e3260ff1 Mon Sep 17 00:00:00 2001 From: lixiaobing1 Date: Mon, 2 Nov 2020 20:22:07 +0800 Subject: [PATCH] fix n to nodeInfo easy to understand --- pkg/scheduler/internal/cache/cache.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/scheduler/internal/cache/cache.go b/pkg/scheduler/internal/cache/cache.go index 2443b6a1fdd2..15461c5e9528 100644 --- a/pkg/scheduler/internal/cache/cache.go +++ b/pkg/scheduler/internal/cache/cache.go @@ -297,25 +297,25 @@ func (cache *schedulerCache) updateNodeInfoSnapshotList(snapshot *Snapshot, upda klog.Error(err) } for _, nodeName := range nodesList { - if n := snapshot.nodeInfoMap[nodeName]; n != nil { - snapshot.nodeInfoList = append(snapshot.nodeInfoList, n) - if len(n.PodsWithAffinity) > 0 { - snapshot.havePodsWithAffinityNodeInfoList = append(snapshot.havePodsWithAffinityNodeInfoList, n) + if nodeInfo := snapshot.nodeInfoMap[nodeName]; nodeInfo != nil { + snapshot.nodeInfoList = append(snapshot.nodeInfoList, nodeInfo) + if len(nodeInfo.PodsWithAffinity) > 0 { + snapshot.havePodsWithAffinityNodeInfoList = append(snapshot.havePodsWithAffinityNodeInfoList, nodeInfo) } - if len(n.PodsWithRequiredAntiAffinity) > 0 { - snapshot.havePodsWithRequiredAntiAffinityNodeInfoList = append(snapshot.havePodsWithRequiredAntiAffinityNodeInfoList, n) + if len(nodeInfo.PodsWithRequiredAntiAffinity) > 0 { + snapshot.havePodsWithRequiredAntiAffinityNodeInfoList = append(snapshot.havePodsWithRequiredAntiAffinityNodeInfoList, nodeInfo) } } else { klog.Errorf("node %q exist in nodeTree but not in NodeInfoMap, this should not happen.", nodeName) } } } else { - for _, n := range snapshot.nodeInfoList { - if len(n.PodsWithAffinity) > 0 { - snapshot.havePodsWithAffinityNodeInfoList = append(snapshot.havePodsWithAffinityNodeInfoList, n) + for _, nodeInfo := range snapshot.nodeInfoList { + if len(nodeInfo.PodsWithAffinity) > 0 { + snapshot.havePodsWithAffinityNodeInfoList = append(snapshot.havePodsWithAffinityNodeInfoList, nodeInfo) } - if len(n.PodsWithRequiredAntiAffinity) > 0 { - snapshot.havePodsWithRequiredAntiAffinityNodeInfoList = append(snapshot.havePodsWithRequiredAntiAffinityNodeInfoList, n) + if len(nodeInfo.PodsWithRequiredAntiAffinity) > 0 { + snapshot.havePodsWithRequiredAntiAffinityNodeInfoList = append(snapshot.havePodsWithRequiredAntiAffinityNodeInfoList, nodeInfo) } } }