Merge pull request #119399 from wackxu/optimizecodeforNodeUnschedulable

Optimize the code of NodeUnschedulable to reduce TolerationsTolerateT…
This commit is contained in:
Kubernetes Prow Robot 2023-08-15 17:14:26 -07:00 committed by GitHub
commit ea30d100f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,14 +61,19 @@ func (pl *NodeUnschedulable) Name() string {
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 {
node := nodeInfo.Node() node := nodeInfo.Node()
if !node.Spec.Unschedulable {
return nil
}
// If pod tolerate unschedulable taint, it's also tolerate `node.Spec.Unschedulable`. // If pod tolerate unschedulable taint, it's also tolerate `node.Spec.Unschedulable`.
podToleratesUnschedulable := v1helper.TolerationsTolerateTaint(pod.Spec.Tolerations, &v1.Taint{ podToleratesUnschedulable := v1helper.TolerationsTolerateTaint(pod.Spec.Tolerations, &v1.Taint{
Key: v1.TaintNodeUnschedulable, Key: v1.TaintNodeUnschedulable,
Effect: v1.TaintEffectNoSchedule, Effect: v1.TaintEffectNoSchedule,
}) })
if node.Spec.Unschedulable && !podToleratesUnschedulable { if !podToleratesUnschedulable {
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnschedulable) return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonUnschedulable)
} }
return nil return nil
} }