Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filterout those nodes which are not helpful for preemptation #3071

Closed
lowang-bh opened this issue Aug 26, 2023 · 1 comment · Fixed by #3432
Closed

filterout those nodes which are not helpful for preemptation #3071

lowang-bh opened this issue Aug 26, 2023 · 1 comment · Fixed by #3432
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@lowang-bh
Copy link
Member

lowang-bh commented Aug 26, 2023

What would you like to be added:

like K8s preemptations, it first filters out those nodes will not help preemption

https://github.com/kubernetes/kubernetes/blob/dbcbf5e952266479df92c84457781c0a2a688afd/pkg/scheduler/framework/preemption/preemption.go#L223C2-L239

        potentialNodes, unschedulableNodeStatus := nodesWherePreemptionMightHelp(allNodes, m)
        if len(potentialNodes) == 0 {
                logger.V(3).Info("Preemption will not help schedule pod on any node", "pod", klog.KObj(pod))
                // In this case, we should clean-up any existing nominated node name of the pod.
                if err := util.ClearNominatedNodeName(ctx, ev.Handler.ClientSet(), pod); err != nil {
                        logger.Error(err, "Could not clear the nominatedNodeName field of pod", "pod", klog.KObj(pod))
                        // We do not return as this error is not critical.
                }
                return nil, unschedulableNodeStatus, nil
        }


        pdbs, err := getPodDisruptionBudgets(ev.PdbLister)
        if err != nil {
                return nil, nil, err
        }


        offset, numCandidates := ev.GetOffsetAndNumCandidates(int32(len(potentialNodes)))

https://github.com/kubernetes/kubernetes/blob/dbcbf5e952266479df92c84457781c0a2a688afd/pkg/scheduler/framework/preemption/preemption.go#L413-L428

// nodesWherePreemptionMightHelp returns a list of nodes with failed predicates
// that may be satisfied by removing pods from the node.
func nodesWherePreemptionMightHelp(nodes []*framework.NodeInfo, m framework.NodeToStatusMap) ([]*framework.NodeInfo, framework.NodeToStatusMap) {
        var potentialNodes []*framework.NodeInfo
        nodeStatuses := make(framework.NodeToStatusMap)
        for _, node := range nodes {
                name := node.Node().Name
                // We rely on the status by each plugin - 'Unschedulable' or 'UnschedulableAndUnresolvable'
                // to determine whether preemption may help or not on the node.
                if m[name].Code() == framework.UnschedulableAndUnresolvable {
                        nodeStatuses[node.Node().Name] = framework.NewStatus(framework.UnschedulableAndUnresolvable, "Preemption is not helpful for scheduling")
                        continue
                }
                potentialNodes = append(potentialNodes, node)
        }
        return potentialNodes, nodeStatuses
}

Why is this needed:

reduce the nodes which need to run filter on them

@tanberBro
Copy link

Which nodes should be filtered first? Unscheduled and unknown?
@lowang-bh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants