Documentation ¶
Index ¶
- type Candidate
- type Evaluator
- func (ev *Evaluator) DryRunPreemption(ctx context.Context, state *framework.CycleState, pod *v1.Pod, ...) ([]Candidate, *framework.NodeToStatus, error)
- func (ev *Evaluator) IsPodRunningPreemption(podUID types.UID) bool
- func (ev *Evaluator) Preempt(ctx context.Context, state *framework.CycleState, pod *v1.Pod, ...) (*framework.PostFilterResult, *framework.Status)
- func (ev *Evaluator) SelectCandidate(ctx context.Context, candidates []Candidate) Candidate
- type Interface
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 // PreemptPod is a function that actually makes API calls to preempt a specific Pod. // This is exposed to be replaced during tests. PreemptPod func(ctx context.Context, c Candidate, preemptor, victim *v1.Pod, pluginName string) error Interface // contains filtered or unexported fields }
func NewEvaluator ¶ added in v1.32.0
func (*Evaluator) DryRunPreemption ¶
func (ev *Evaluator) DryRunPreemption(ctx context.Context, state *framework.CycleState, pod *v1.Pod, potentialNodes []*framework.NodeInfo, pdbs []*policy.PodDisruptionBudget, offset int32, candidatesNum int32) ([]Candidate, *framework.NodeToStatus, 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) IsPodRunningPreemption ¶ added in v1.32.0
IsPodRunningPreemption returns true if the pod is currently triggering preemption asynchronously.
func (*Evaluator) Preempt ¶
func (ev *Evaluator) Preempt(ctx context.Context, state *framework.CycleState, pod *v1.Pod, m framework.NodeToStatusReader) (*framework.PostFilterResult, *framework.Status)
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.
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(ctx context.Context, 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) // OrderedScoreFuncs returns a list of ordered score functions to select preferable node where victims will be preempted. // The ordered score functions will be processed one by one iff we find more than one node with the highest score. // Default score functions will be processed if nil returned here for backwards-compatibility. OrderedScoreFuncs(ctx context.Context, nodesToVictims map[string]*extenderv1.Victims) []func(node string) int64 }
Interface is expected to be implemented by different preemption plugins as all those member methods might have different behavior compared with the default preemption.