Skip to content

Commit 2c51c13

Browse files
committed
Scheduler NodeInfo cleanup
1 parent 0c9245a commit 2c51c13

File tree

27 files changed

+246
-378
lines changed

27 files changed

+246
-378
lines changed

pkg/scheduler/core/extender.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (h *HTTPExtender) convertToNodeToVictims(
287287
func (h *HTTPExtender) convertPodUIDToPod(
288288
metaPod *extenderv1.MetaPod,
289289
nodeInfo *framework.NodeInfo) (*v1.Pod, error) {
290-
for _, p := range nodeInfo.Pods() {
290+
for _, p := range nodeInfo.Pods {
291291
if string(p.Pod.UID) == metaPod.UID {
292292
return p.Pod, nil
293293
}

pkg/scheduler/core/extender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender(pod *v1.Pod, node *v1.Node)
225225
// As the first step, remove all the lower priority pods from the node and
226226
// check if the given pod can be scheduled.
227227
podPriority := podutil.GetPodPriority(pod)
228-
for _, p := range nodeInfoCopy.Pods() {
228+
for _, p := range nodeInfoCopy.Pods {
229229
if podutil.GetPodPriority(p.Pod) < podPriority {
230230
potentialVictims = append(potentialVictims, p.Pod)
231231
removePod(p.Pod)

pkg/scheduler/core/generic_scheduler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ func (g *genericScheduler) selectVictimsOnNode(
970970
// As the first step, remove all the lower priority pods from the node and
971971
// check if the given pod can be scheduled.
972972
podPriority := podutil.GetPodPriority(pod)
973-
for _, p := range nodeInfo.Pods() {
973+
for _, p := range nodeInfo.Pods {
974974
if podutil.GetPodPriority(p.Pod) < podPriority {
975975
potentialVictims = append(potentialVictims, p.Pod)
976976
if err := removePod(p.Pod); err != nil {
@@ -1062,7 +1062,7 @@ func podEligibleToPreemptOthers(pod *v1.Pod, nodeInfos framework.NodeInfoLister,
10621062
if len(nomNodeName) > 0 {
10631063
if nodeInfo, _ := nodeInfos.Get(nomNodeName); nodeInfo != nil {
10641064
podPriority := podutil.GetPodPriority(pod)
1065-
for _, p := range nodeInfo.Pods() {
1065+
for _, p := range nodeInfo.Pods {
10661066
if p.Pod.DeletionTimestamp != nil && podutil.GetPodPriority(p.Pod) < podPriority {
10671067
// There is a terminating pod on the nominated node.
10681068
return false

pkg/scheduler/core/generic_scheduler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (pl *noPodsFilterPlugin) Name() string {
135135

136136
// Filter invoked at the filter extension point.
137137
func (pl *noPodsFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status {
138-
if len(nodeInfo.Pods()) == 0 {
138+
if len(nodeInfo.Pods) == 0 {
139139
return nil
140140
}
141141
return framework.NewStatus(framework.Unschedulable, ErrReasonFake)

pkg/scheduler/framework/plugins/defaultpodtopologyspread/default_pod_topology_spread.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ func New(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin
196196

197197
// countMatchingPods counts pods based on namespace and matching all selectors
198198
func countMatchingPods(namespace string, selector labels.Selector, nodeInfo *framework.NodeInfo) int {
199-
if len(nodeInfo.Pods()) == 0 || selector.Empty() {
199+
if len(nodeInfo.Pods) == 0 || selector.Empty() {
200200
return 0
201201
}
202202
count := 0
203-
for _, p := range nodeInfo.Pods() {
203+
for _, p := range nodeInfo.Pods {
204204
// Ignore pods being deleted for spreading purposes
205205
// Similar to how it is done for SelectorSpreadPriority
206206
if namespace == p.Pod.Namespace && p.Pod.DeletionTimestamp == nil {

pkg/scheduler/framework/plugins/imagelocality/image_locality.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ func calculatePriority(sumScores int64) int64 {
9595
// the final score. Note that the init containers are not considered for it's rare for users to deploy huge init containers.
9696
func sumImageScores(nodeInfo *framework.NodeInfo, containers []v1.Container, totalNumNodes int) int64 {
9797
var sum int64
98-
imageStates := nodeInfo.ImageStates()
99-
10098
for _, container := range containers {
101-
if state, ok := imageStates[normalizedImageName(container.Image)]; ok {
99+
if state, ok := nodeInfo.ImageStates[normalizedImageName(container.Image)]; ok {
102100
sum += scaledImageScore(state, totalNumNodes)
103101
}
104102
}
105-
106103
return sum
107104
}
108105

pkg/scheduler/framework/plugins/interpodaffinity/filtering.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func getTPMapMatchingExistingAntiAffinity(pod *v1.Pod, allNodes []*framework.Nod
228228
klog.Error("node not found")
229229
return
230230
}
231-
for _, existingPod := range nodeInfo.PodsWithAffinity() {
231+
for _, existingPod := range nodeInfo.PodsWithAffinity {
232232
existingPodTopologyMaps, err := getMatchingAntiAffinityTopologyPairsOfPod(pod, existingPod.Pod, node)
233233
if err != nil {
234234
errCh.SendErrorWithCancel(err, cancel)
@@ -291,7 +291,7 @@ func getTPMapMatchingIncomingAffinityAntiAffinity(pod *v1.Pod, allNodes []*frame
291291
}
292292
nodeTopologyPairsAffinityPodsMap := make(topologyToMatchedTermCount)
293293
nodeTopologyPairsAntiAffinityPodsMap := make(topologyToMatchedTermCount)
294-
for _, existingPod := range nodeInfo.Pods() {
294+
for _, existingPod := range nodeInfo.Pods {
295295
// Check affinity terms.
296296
nodeTopologyPairsAffinityPodsMap.updateWithAffinityTerms(existingPod.Pod, node, affinityTerms, 1)
297297

pkg/scheduler/framework/plugins/interpodaffinity/scoring.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ func (pl *InterPodAffinity) PreScore(
239239
}
240240
// Unless the pod being scheduled has affinity terms, we only
241241
// need to process pods with affinity in the node.
242-
podsToProcess := nodeInfo.PodsWithAffinity()
242+
podsToProcess := nodeInfo.PodsWithAffinity
243243
if hasAffinityConstraints || hasAntiAffinityConstraints {
244244
// We need to process all the pods.
245-
podsToProcess = nodeInfo.Pods()
245+
podsToProcess = nodeInfo.Pods
246246
}
247247

248248
topoScore := make(scoreMap)

pkg/scheduler/framework/plugins/nodeports/node_ports.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func Fits(pod *v1.Pod, nodeInfo *framework.NodeInfo) bool {
118118

119119
func fitsPorts(wantPorts []*v1.ContainerPort, nodeInfo *framework.NodeInfo) bool {
120120
// try to see whether existingPorts and wantPorts will conflict or not
121-
existingPorts := nodeInfo.UsedPorts()
121+
existingPorts := nodeInfo.UsedPorts
122122
for _, cp := range wantPorts {
123123
if existingPorts.CheckConflict(cp.HostIP, string(cp.Protocol), cp.HostPort) {
124124
return false

pkg/scheduler/framework/plugins/noderesources/balanced_allocation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func TestNodeResourcesBalancedAllocation(t *testing.T) {
384384
maxVolumes := 5
385385
nodeInfoList, _ := snapshot.NodeInfos().List()
386386
for _, info := range nodeInfoList {
387-
info.TransientInfo.TransNodeInfo.AllocatableVolumesCount = getExistingVolumeCountForNode(info.Pods(), maxVolumes)
387+
info.TransientInfo.TransNodeInfo.AllocatableVolumesCount = getExistingVolumeCountForNode(info.Pods, maxVolumes)
388388
info.TransientInfo.TransNodeInfo.RequestedVolumes = len(test.pod.Spec.Volumes)
389389
}
390390
}

0 commit comments

Comments
 (0)