mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #47052 from gyliu513/godoc
Automatic merge from submit-queue godoc update for scheduler predicates. **What this PR does / why we need it**: This is a follow up PR for https://github.com/kubernetes/kubernetes/pull/46621 /cc @timothysc **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note none ```
This commit is contained in:
		@@ -564,6 +564,9 @@ func podName(pod *v1.Pod) string {
 | 
			
		||||
	return pod.Namespace + "/" + pod.Name
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PodFitsResources checks if a node has sufficient resources, such as cpu, memory, gpu, opaque int resources etc to run a pod.
 | 
			
		||||
// First return value indicates whether a node has sufficient resources to run a pod while the second return value indicates the
 | 
			
		||||
// predicate failure reasons if the node has insufficient resources to run the pod.
 | 
			
		||||
func PodFitsResources(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	node := nodeInfo.Node()
 | 
			
		||||
	if node == nil {
 | 
			
		||||
@@ -693,6 +696,7 @@ func podMatchesNodeLabels(pod *v1.Pod, node *v1.Node) bool {
 | 
			
		||||
	return nodeAffinityMatches
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PodMatchNodeSelector checks if a pod node selector matches the node label.
 | 
			
		||||
func PodMatchNodeSelector(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	node := nodeInfo.Node()
 | 
			
		||||
	if node == nil {
 | 
			
		||||
@@ -704,6 +708,7 @@ func PodMatchNodeSelector(pod *v1.Pod, meta interface{}, nodeInfo *schedulercach
 | 
			
		||||
	return false, []algorithm.PredicateFailureReason{ErrNodeSelectorNotMatch}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PodFitsHost checks if a pod spec node name matches the current node.
 | 
			
		||||
func PodFitsHost(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	if len(pod.Spec.NodeName) == 0 {
 | 
			
		||||
		return true, nil, nil
 | 
			
		||||
@@ -864,6 +869,7 @@ func (s *ServiceAffinity) checkServiceAffinity(pod *v1.Pod, meta interface{}, no
 | 
			
		||||
	return false, []algorithm.PredicateFailureReason{ErrServiceAffinityViolated}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PodFitsHostPorts checks if a node has free ports for the requested pod ports.
 | 
			
		||||
func PodFitsHostPorts(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	var wantPorts map[int]bool
 | 
			
		||||
	if predicateMeta, ok := meta.(*predicateMetadata); ok {
 | 
			
		||||
@@ -897,6 +903,8 @@ func haveSame(a1, a2 []string) bool {
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GeneralPredicates checks whether noncriticalPredicates and EssentialPredicates pass. noncriticalPredicates are the predicates
 | 
			
		||||
// that only non-critical pods need and EssentialPredicates are the predicates that all pods, including critical pods, need
 | 
			
		||||
func GeneralPredicates(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	var predicateFails []algorithm.PredicateFailureReason
 | 
			
		||||
	fit, reasons, err := noncriticalPredicates(pod, meta, nodeInfo)
 | 
			
		||||
@@ -976,6 +984,9 @@ func NewPodAffinityPredicate(info NodeInfo, podLister algorithm.PodLister) algor
 | 
			
		||||
	return checker.InterPodAffinityMatches
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InterPodAffinityMatches checks if a pod can be scheduled on the specified node with pod affinity/anti-affinity configuration.
 | 
			
		||||
// First return value indicates whether a pod can be scheduled on the specified node while the second return value indicates the
 | 
			
		||||
// predicate failure reasons if the pod cannot be scheduled on the specified node.
 | 
			
		||||
func (c *PodAffinityChecker) InterPodAffinityMatches(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	node := nodeInfo.Node()
 | 
			
		||||
	if node == nil {
 | 
			
		||||
@@ -1234,6 +1245,7 @@ func (c *PodAffinityChecker) satisfiesPodsAffinityAntiAffinity(pod *v1.Pod, node
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PodToleratesNodeTaints checks if a pod tolertaions can tolerate the node taints
 | 
			
		||||
func PodToleratesNodeTaints(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
 | 
			
		||||
	taints, err := nodeInfo.Taints()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user