add missing implementations in 1.18
This commit is contained in:
parent
dadb68fb8b
commit
6661d32643
|
|
@ -81,7 +81,7 @@ func (estimator *BinpackingNodeEstimator) Estimate(
|
|||
for _, podInfo := range podInfos {
|
||||
found := false
|
||||
|
||||
nodeName, err := estimator.predicateChecker.FitsAnyNodeMatching(estimator.clusterSnapshot, podInfo.pod, func(nodeInfo *schedulerframework.NodeInfo) bool {
|
||||
nodeName, err := estimator.predicateChecker.FitsAnyNodeMatching(estimator.clusterSnapshot, podInfo.pod, func(nodeInfo *schedulernodeinfo.NodeInfo) bool {
|
||||
return newNodeNames[nodeInfo.Node().Name]
|
||||
})
|
||||
if err == nil {
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ package simulator
|
|||
|
||||
import (
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
||||
)
|
||||
|
||||
// PredicateChecker checks whether all required predicates pass for given Pod and Node.
|
||||
type PredicateChecker interface {
|
||||
FitsAnyNode(clusterSnapshot ClusterSnapshot, pod *apiv1.Pod) (string, error)
|
||||
FitsAnyNodeMatching(clusterSnapshot ClusterSnapshot, pod *apiv1.Pod, nodeMatches func(*schedulernodeinfo.NodeInfo) bool) (string, error)
|
||||
CheckPredicates(clusterSnapshot ClusterSnapshot, pod *apiv1.Pod, nodeName string) *PredicateError
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,13 @@ func NewSchedulerBasedPredicateChecker(kubeClient kube_client.Interface, stop <-
|
|||
|
||||
// FitsAnyNode checks if the given pod can be placed on any of the given nodes.
|
||||
func (p *SchedulerBasedPredicateChecker) FitsAnyNode(clusterSnapshot ClusterSnapshot, pod *apiv1.Pod) (string, error) {
|
||||
return p.FitsAnyNodeMatching(clusterSnapshot, pod, func(*scheduler_nodeinfo.NodeInfo) bool {
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// FitsAnyNodeMatching checks if the given pod can be placed on any of the given nodes matching the provided function.
|
||||
func (p *SchedulerBasedPredicateChecker) FitsAnyNodeMatching(clusterSnapshot ClusterSnapshot, pod *apiv1.Pod, nodeMatches func(*scheduler_nodeinfo.NodeInfo) bool) (string, error) {
|
||||
if clusterSnapshot == nil {
|
||||
return "", fmt.Errorf("ClusterSnapshot not provided")
|
||||
}
|
||||
|
|
@ -113,6 +120,10 @@ func (p *SchedulerBasedPredicateChecker) FitsAnyNode(clusterSnapshot ClusterSnap
|
|||
}
|
||||
|
||||
for _, nodeInfo := range nodeInfosList {
|
||||
if !nodeMatches(nodeInfo) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Be sure that the node is schedulable.
|
||||
if nodeInfo.Node().Spec.Unschedulable {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue