From 034b10741300512ca4f4fea0c8f0ab1dd5a39f31 Mon Sep 17 00:00:00 2001 From: Jiawen Liu Date: Wed, 6 Nov 2024 16:12:37 +0800 Subject: [PATCH] refactor: delete the handle parameter in updateStateByVictims function --- .../framework/plugins/interpodaffinity/interpodaffinity.go | 6 +++--- .../plugins/podtopologyspread/podtopologyspread.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/binder/framework/plugins/interpodaffinity/interpodaffinity.go b/pkg/binder/framework/plugins/interpodaffinity/interpodaffinity.go index 4210bac5..8224b416 100644 --- a/pkg/binder/framework/plugins/interpodaffinity/interpodaffinity.go +++ b/pkg/binder/framework/plugins/interpodaffinity/interpodaffinity.go @@ -70,7 +70,7 @@ func (pl *InterPodAffinity) CheckTopology(_ context.Context, cycleState *framewo return framework.NewStatus(framework.Error, err.Error()) } if commonState != nil { - pl.updateStateByVictims(state, pl.frameworkHandle, commonState.VictimsGroupByNode, pod) + pl.updateStateByVictims(state, commonState.VictimsGroupByNode, pod) } if !utils.SatisfyPodAffinity(state, nodeInfo, podLauncher) { @@ -94,9 +94,9 @@ func New(_ runtime.Object, handle handle.BinderFrameworkHandle) (framework.Plugi }, nil } -func (pl *InterPodAffinity) updateStateByVictims(state *utils.PreFilterState, handle handle.BinderFrameworkHandle, victimsGroupByNode map[string]map[types.UID]*v1.Pod, targetPod *v1.Pod) error { +func (pl *InterPodAffinity) updateStateByVictims(state *utils.PreFilterState, victimsGroupByNode map[string]map[types.UID]*v1.Pod, targetPod *v1.Pod) error { for nodeName, victimsMap := range victimsGroupByNode { - nodeInfo := handle.GetNodeInfo(nodeName) + nodeInfo := pl.frameworkHandle.GetNodeInfo(nodeName) if nodeInfo == nil { continue } diff --git a/pkg/binder/framework/plugins/podtopologyspread/podtopologyspread.go b/pkg/binder/framework/plugins/podtopologyspread/podtopologyspread.go index f56e1e0f..57b41796 100644 --- a/pkg/binder/framework/plugins/podtopologyspread/podtopologyspread.go +++ b/pkg/binder/framework/plugins/podtopologyspread/podtopologyspread.go @@ -77,7 +77,7 @@ func (pl *PodTopologySpreadCheck) CheckTopology(_ context.Context, cycleState *f return framework.NewStatus(framework.Error, err.Error()) } if commonState != nil { - pl.updateStateByVictims(&state, pl.frameworkHandle, commonState.VictimsGroupByNode) + pl.updateStateByVictims(&state, commonState.VictimsGroupByNode) } return utils.IsSatisfyPodTopologySpreadConstraints(&state, pod, nodeInfo, podLauncher) @@ -145,9 +145,9 @@ func (pl *PodTopologySpreadCheck) getConstraints(pod *v1.Pod) ([]utils.TopologyS return constraints, nil } -func (pl *PodTopologySpreadCheck) updateStateByVictims(state *utils.PreFilterState, handle handle.BinderFrameworkHandle, victimsGroupByNode map[string]map[types.UID]*v1.Pod) error { +func (pl *PodTopologySpreadCheck) updateStateByVictims(state *utils.PreFilterState, victimsGroupByNode map[string]map[types.UID]*v1.Pod) error { for nodeName, victimsMap := range victimsGroupByNode { - nodeInfo := handle.GetNodeInfo(nodeName) + nodeInfo := pl.frameworkHandle.GetNodeInfo(nodeName) if nodeInfo == nil { continue }