preemption

package
v1.26.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 23 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate interface {
	// Victims wraps a list of to-be-preempted Pods and the number of PDB violation.
	Victims() *extenderv1.Victims
	// Name returns the target node name where the preemptor gets nominated to run.
	Name() string
}

Candidate represents a nominated node on which the preemptor can be scheduled, along with the list of victims that should be evicted for the preemptor to fit the node.

type Evaluator

type Evaluator struct {
	PluginName string
	Handler    framework.Handle
	PodLister  corelisters.PodLister
	PdbLister  policylisters.PodDisruptionBudgetLister
	State      *framework.CycleState
	Interface
}

func (*Evaluator) DryRunPreemption

func (ev *Evaluator) DryRunPreemption(ctx context.Context, pod *v1.Pod, potentialNodes []*framework.NodeInfo,
	pdbs []*policy.PodDisruptionBudget, offset int32, numCandidates int32) ([]Candidate, framework.NodeToStatusMap, error)

DryRunPreemption simulates Preemption logic on <potentialNodes> in parallel, returns preemption candidates and a map indicating filtered nodes statuses. The number of candidates depends on the constraints defined in the plugin's args. In the returned list of candidates, ones that do not violate PDB are preferred over ones that do. NOTE: This method is exported for easier testing in default preemption.

func (*Evaluator) Preempt

Preempt returns a PostFilterResult carrying suggested nominatedNodeName, along with a Status. The semantics of returned <PostFilterResult, Status> varies on different scenarios:

  • <nil, Error>. This denotes it's a transient/rare error that may be self-healed in future cycles.

  • <nil, Unschedulable>. This status is mostly as expected like the preemptor is waiting for the victims to be fully terminated.

  • In both cases above, a nil PostFilterResult is returned to keep the pod's nominatedNodeName unchanged.

  • <non-nil PostFilterResult, Unschedulable>. It indicates the pod cannot be scheduled even with preemption. In this case, a non-nil PostFilterResult is returned and result.NominatingMode instructs how to deal with the nominatedNodeName.

  • <non-nil PostFilterResult}, Success>. It's the regular happy path and the non-empty nominatedNodeName will be applied to the preemptor pod.

func (*Evaluator) SelectCandidate

func (ev *Evaluator) SelectCandidate(candidates []Candidate) Candidate

SelectCandidate chooses the best-fit candidate from given <candidates> and return it. NOTE: This method is exported for easier testing in default preemption.

type Interface

type Interface interface {
	// GetOffsetAndNumCandidates chooses a random offset and calculates the number of candidates that should be
	// shortlisted for dry running preemption.
	GetOffsetAndNumCandidates(nodes int32) (int32, int32)
	// CandidatesToVictimsMap builds a map from the target node to a list of to-be-preempted Pods and the number of PDB violation.
	CandidatesToVictimsMap(candidates []Candidate) map[string]*extenderv1.Victims
	// 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.
	PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string)
	// 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.
	// Note that both `state` and `nodeInfo` are deep copied.
	SelectVictimsOnNode(ctx context.Context, state *framework.CycleState,
		pod *v1.Pod, nodeInfo *framework.NodeInfo, pdbs []*policy.PodDisruptionBudget) ([]*v1.Pod, int, *framework.Status)
}

Interface is expected to be implemented by different preemption plugins as all those member methods might have different behavior compared with the default preemption.

Jump to

Keyboard shortcuts

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