const Name … type DefaultPreemption … var _ … // Name returns name of the plugin. It is used in logs, etc. func (pl *DefaultPreemption) Name() string { … } // New initializes a new plugin and returns it. func New(_ context.Context, dpArgs runtime.Object, fh framework.Handle, fts feature.Features) (framework.Plugin, error) { … } // PostFilter invoked at the postFilter extension point. func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.CycleState, pod *v1.Pod, m framework.NodeToStatusReader) (*framework.PostFilterResult, *framework.Status) { … } // calculateNumCandidates returns the number of candidates the FindCandidates // method must produce from dry running based on the constraints given by // <minCandidateNodesPercentage> and <minCandidateNodesAbsolute>. The number of // candidates returned will never be greater than <numNodes>. func (pl *DefaultPreemption) calculateNumCandidates(numNodes int32) int32 { … } // GetOffsetAndNumCandidates chooses a random offset and calculates the number // of candidates that should be shortlisted for dry running preemption. func (pl *DefaultPreemption) GetOffsetAndNumCandidates(numNodes int32) (int32, int32) { … } // This function is not applicable for out-of-tree preemption plugins that exercise // different preemption candidates on the same nominated node. func (pl *DefaultPreemption) CandidatesToVictimsMap(candidates []preemption.Candidate) map[string]*extenderv1.Victims { … } // SelectVictimsOnNode finds minimum set of pods on the given node that should be preempted in order to make enough room // for "pod" to be scheduled. func (pl *DefaultPreemption) SelectVictimsOnNode( ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo, pdbs []*policy.PodDisruptionBudget) ([]*v1.Pod, int, *framework.Status) { … } // PodEligibleToPreemptOthers returns one bool and one string. The bool // indicates whether this pod should be considered for preempting other pods or // not. The string includes the reason if this pod isn't eligible. // There're several reasons: // 1. The pod has a preemptionPolicy of Never. // 2. The pod has already preempted other pods and the victims are in their graceful termination period. // Currently we check the node that is nominated for this pod, and as long as there are // terminating pods on this node, we don't attempt to preempt more pods. func (pl *DefaultPreemption) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) { … } // OrderedScoreFuncs returns a list of ordered score functions to select preferable node where victims will be preempted. func (pl *DefaultPreemption) OrderedScoreFuncs(ctx context.Context, nodesToVictims map[string]*extenderv1.Victims) []func(node string) int64 { … } // podTerminatingByPreemption returns true if the pod is in the termination state caused by scheduler preemption. func podTerminatingByPreemption(p *v1.Pod) bool { … } // filterPodsWithPDBViolation groups the given "pods" into two groups of "violatingPods" // and "nonViolatingPods" based on whether their PDBs will be violated if they are // preempted. // This function is stable and does not change the order of received pods. So, if it // receives a sorted list, grouping will preserve the order of the input list. func filterPodsWithPDBViolation(podInfos []*framework.PodInfo, pdbs []*policy.PodDisruptionBudget) (violatingPodInfos, nonViolatingPodInfos []*framework.PodInfo) { … } func getPDBLister(informerFactory informers.SharedInformerFactory) policylisters.PodDisruptionBudgetLister { … }