func()

in pkg/plugin/predicates/predicate_manager.go [130:168]


func (p *predicateManagerImpl) PreemptionPredicates(pod *v1.Pod, node *framework.NodeInfo, victims []*v1.Pod, startIndex int) (index int, ok bool) {
	ctx := context.Background()
	state := framework.NewCycleState()

	// run prefilter checks as pod cannot be scheduled otherwise
	s, plugin, skip := p.runPreFilterPlugins(ctx, state, *p.allocationPreFilters, pod, node)
	if !s.IsSuccess() && !s.IsSkip() {
		// prefilter check failed, log and return
		log.Log(log.ShimPredicates).Debug("PreFilter check failed during preemption check",
			zap.String("podUID", string(pod.UID)),
			zap.String("plugin", plugin),
			zap.String("message", s.Message()))

		return -1, false
	}

	// clone node so that we can modify it here for predicate checks
	preemptingNode := node.Clone()

	// remove pods up through startIndex -- all of these are required to be removed to satisfy resource constraints
	for i := 0; i < startIndex && i < len(victims); i++ {
		removePodFromNodeNoFail(preemptingNode, victims[i])
	}

	// loop through remaining pods
	for i := startIndex; i < len(victims); i++ {
		removePodFromNodeNoFail(preemptingNode, victims[i])
		status, _ := p.runFilterPlugins(ctx, *p.allocationFilters, state, pod, preemptingNode, skip)
		if status.IsSuccess() {
			return i, true
		}
	}

	// no fit, log and return
	log.Log(log.ShimPredicates).Debug("Filter checks failed during preemption check, no fit",
		zap.String("podUID", string(pod.UID)),
		zap.String("nodeID", node.Node().Name))
	return -1, false
}