defaultpreemption

package
v1.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 24 Imported by: 11

Documentation

Index

Constants

Name of the plugin used in the plugin registry and configurations.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultPreemption

type DefaultPreemption struct {
	Evaluator *preemption.Evaluator

	// IsEligiblePod returns whether a victim pod is allowed to be preempted by a preemptor pod.
	// This filtering is in addition to the internal requirement that the victim pod have lower
	// priority than the preemptor pod. Any customizations should always allow system services
	// to preempt normal pods, to avoid problems if system pods are unable to find space.
	IsEligiblePod IsEligiblePodFunc

	// MoreImportantPod is used to sort eligible victims in-place in descending order of highest to
	// lowest importance. Pods with higher importance are less likely to be preempted.
	// The default behavior is to order pods by descending priority, then descending runtime duration
	// for pods with equal priority.
	MoreImportantPod MoreImportantPodFunc
	// contains filtered or unexported fields
}

DefaultPreemption is a PostFilter plugin implements the preemption logic.

func New

New initializes a new plugin and returns it. The plugin type is retained to allow modification.

func (*DefaultPreemption) CandidatesToVictimsMap added in v1.23.0

func (pl *DefaultPreemption) CandidatesToVictimsMap(candidates []preemption.Candidate) map[string]*extenderv1.Victims

This function is not applicable for out-of-tree preemption plugins that exercise different preemption candidates on the same nominated node.

func (*DefaultPreemption) EventsToRegister added in v1.32.0

func (pl *DefaultPreemption) EventsToRegister(_ context.Context) ([]fwk.ClusterEventWithHint, error)

EventsToRegister returns the possible events that may make a Pod failed by this plugin schedulable.

func (*DefaultPreemption) GetOffsetAndNumCandidates added in v1.23.0

func (pl *DefaultPreemption) GetOffsetAndNumCandidates(numNodes int32) (int32, int32)

GetOffsetAndNumCandidates chooses a random offset and calculates the number of candidates that should be shortlisted for dry running preemption.

func (*DefaultPreemption) Name

func (pl *DefaultPreemption) Name() string

Name returns name of the plugin. It is used in logs, etc.

func (*DefaultPreemption) OrderedScoreFuncs added in v1.29.0

func (pl *DefaultPreemption) OrderedScoreFuncs(ctx context.Context, nodesToVictims map[string]*extenderv1.Victims) []func(node string) int64

OrderedScoreFuncs returns a list of ordered score functions to select preferable node where victims will be preempted.

func (*DefaultPreemption) PodEligibleToPreemptOthers added in v1.23.0

func (pl *DefaultPreemption) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *fwk.Status) (bool, string)

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 (*DefaultPreemption) PostFilter

PostFilter invoked at the postFilter extension point.

func (*DefaultPreemption) PreEnqueue added in v1.32.0

func (pl *DefaultPreemption) PreEnqueue(ctx context.Context, p *v1.Pod) *fwk.Status

func (*DefaultPreemption) SelectVictimsOnNode added in v1.23.0

func (pl *DefaultPreemption) SelectVictimsOnNode(
	ctx context.Context,
	state fwk.CycleState,
	pod *v1.Pod,
	nodeInfo fwk.NodeInfo,
	pdbs []*policy.PodDisruptionBudget) ([]*v1.Pod, int, *fwk.Status)

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.

type IsEligiblePodFunc added in v1.34.0

type IsEligiblePodFunc func(nodeInfo fwk.NodeInfo, victim fwk.PodInfo, preemptor *v1.Pod) bool

IsEligiblePodFunc is a function which may be assigned to the DefaultPreemption plugin. This may implement rules/filtering around preemption eligibility, which is in addition to the internal requirement that the victim pod have lower priority than the preemptor pod. Any customizations should always allow system services to preempt normal pods, to avoid problems if system pods are unable to find space.

type MoreImportantPodFunc added in v1.34.0

type MoreImportantPodFunc func(pod1, pod2 *v1.Pod) bool

MoreImportantPodFunc is a function which may be assigned to the DefaultPreemption plugin. Implementations should return true if the first pod is more important than the second pod and the second one should be considered for preemption before the first one. For performance reasons, the search for nodes eligible for preemption is done by omitting all eligible victims from a node then checking whether the preemptor fits on the node without them, before adding back victims (starting from the most important) that still fit with the preemptor. The default behavior is to not consider pod affinity between the preemptor and the victims, as affinity between pods that are eligible to preempt each other isn't recommended.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL