mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Optimize the code of NodeUnschedulable to reduce TolerationsTolerateTaint function calls
Signed-off-by: wackxu <xushiwei5@huawei.com>
This commit is contained in:
		@@ -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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user