From 97d9d2bd179fc0a01851ffc54b82f6c30b44c92d Mon Sep 17 00:00:00 2001 From: SataQiu Date: Fri, 15 Jul 2022 00:09:42 +0800 Subject: [PATCH] scheduler: remove useless null pointer check about nodeInfo for in-tree plugins --- .../plugins/nodeunschedulable/node_unschedulable.go | 5 +++-- .../framework/plugins/tainttoleration/taint_toleration.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/framework/plugins/nodeunschedulable/node_unschedulable.go b/pkg/scheduler/framework/plugins/nodeunschedulable/node_unschedulable.go index c6537fb2dc1..f9c147560dc 100644 --- a/pkg/scheduler/framework/plugins/nodeunschedulable/node_unschedulable.go +++ b/pkg/scheduler/framework/plugins/nodeunschedulable/node_unschedulable.go @@ -59,7 +59,8 @@ func (pl *NodeUnschedulable) Name() string { // Filter invoked at the filter extension point. func (pl *NodeUnschedulable) Filter(ctx context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { - if nodeInfo == nil || nodeInfo.Node() == nil { + node := nodeInfo.Node() + if node == nil { return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnknownCondition) } // If pod tolerate unschedulable taint, it's also tolerate `node.Spec.Unschedulable`. @@ -68,7 +69,7 @@ func (pl *NodeUnschedulable) Filter(ctx context.Context, _ *framework.CycleState Effect: v1.TaintEffectNoSchedule, }) // TODO (k82cn): deprecates `node.Spec.Unschedulable` in 1.13. - if nodeInfo.Node().Spec.Unschedulable && !podToleratesUnschedulable { + if node.Spec.Unschedulable && !podToleratesUnschedulable { return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnschedulable) } return nil diff --git a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go index 9420c06c6ea..cc9db39b25f 100644 --- a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go +++ b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go @@ -62,7 +62,8 @@ func (pl *TaintToleration) EventsToRegister() []framework.ClusterEvent { // Filter invoked at the filter extension point. func (pl *TaintToleration) Filter(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { - if nodeInfo == nil || nodeInfo.Node() == nil { + node := nodeInfo.Node() + if node == nil { return framework.AsStatus(fmt.Errorf("invalid nodeInfo")) } @@ -71,7 +72,7 @@ func (pl *TaintToleration) Filter(ctx context.Context, state *framework.CycleSta return t.Effect == v1.TaintEffectNoSchedule || t.Effect == v1.TaintEffectNoExecute } - taint, isUntolerated := v1helper.FindMatchingUntoleratedTaint(nodeInfo.Node().Spec.Taints, pod.Spec.Tolerations, filterPredicate) + taint, isUntolerated := v1helper.FindMatchingUntoleratedTaint(node.Spec.Taints, pod.Spec.Tolerations, filterPredicate) if !isUntolerated { return nil }