Merge pull request #111153 from SataQiu/fix-scheduler-20220715

scheduler: remove useless null pointer check about nodeInfo for in-tree plugins
This commit is contained in:
Kubernetes Prow Robot 2022-07-18 15:36:37 -07:00 committed by GitHub
commit 93b6af95a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -59,7 +59,8 @@ func (pl *NodeUnschedulable) Name() string {
// Filter invoked at the filter extension point. // Filter invoked at the filter extension point.
func (pl *NodeUnschedulable) Filter(ctx context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { 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) return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnknownCondition)
} }
// If pod tolerate unschedulable taint, it's also tolerate `node.Spec.Unschedulable`. // 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, Effect: v1.TaintEffectNoSchedule,
}) })
// TODO (k82cn): deprecates `node.Spec.Unschedulable` in 1.13. // 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 framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnschedulable)
} }
return nil return nil

View File

@ -62,7 +62,8 @@ func (pl *TaintToleration) EventsToRegister() []framework.ClusterEvent {
// Filter invoked at the filter extension point. // 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 { 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")) 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 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 { if !isUntolerated {
return nil return nil
} }