mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-23 00:07:31 +00:00
feature(KEP-4832): asynchronous preemption
This commit is contained in:
@@ -53,6 +53,7 @@ type DefaultPreemption struct {
|
||||
args config.DefaultPreemptionArgs
|
||||
podLister corelisters.PodLister
|
||||
pdbLister policylisters.PodDisruptionBudgetLister
|
||||
Evaluator *preemption.Evaluator
|
||||
}
|
||||
|
||||
var _ framework.PostFilterPlugin = &DefaultPreemption{}
|
||||
@@ -71,13 +72,19 @@ func New(_ context.Context, dpArgs runtime.Object, fh framework.Handle, fts feat
|
||||
if err := validation.ValidateDefaultPreemptionArgs(nil, args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
podLister := fh.SharedInformerFactory().Core().V1().Pods().Lister()
|
||||
pdbLister := getPDBLister(fh.SharedInformerFactory())
|
||||
|
||||
pl := DefaultPreemption{
|
||||
fh: fh,
|
||||
fts: fts,
|
||||
args: *args,
|
||||
podLister: fh.SharedInformerFactory().Core().V1().Pods().Lister(),
|
||||
pdbLister: getPDBLister(fh.SharedInformerFactory()),
|
||||
podLister: podLister,
|
||||
pdbLister: pdbLister,
|
||||
}
|
||||
pl.Evaluator = preemption.NewEvaluator(Name, fh, &pl, fts.EnableAsyncPreemption)
|
||||
|
||||
return &pl, nil
|
||||
}
|
||||
|
||||
@@ -87,16 +94,7 @@ func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.Cy
|
||||
metrics.PreemptionAttempts.Inc()
|
||||
}()
|
||||
|
||||
pe := preemption.Evaluator{
|
||||
PluginName: names.DefaultPreemption,
|
||||
Handler: pl.fh,
|
||||
PodLister: pl.podLister,
|
||||
PdbLister: pl.pdbLister,
|
||||
State: state,
|
||||
Interface: pl,
|
||||
}
|
||||
|
||||
result, status := pe.Preempt(ctx, pod, m)
|
||||
result, status := pl.Evaluator.Preempt(ctx, state, pod, m)
|
||||
msg := status.Message()
|
||||
if len(msg) > 0 {
|
||||
return result, framework.NewStatus(status.Code(), "preemption: "+msg)
|
||||
@@ -104,6 +102,22 @@ func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.Cy
|
||||
return result, status
|
||||
}
|
||||
|
||||
func (pl *DefaultPreemption) PreEnqueue(ctx context.Context, p *v1.Pod) *framework.Status {
|
||||
if !pl.fts.EnableAsyncPreemption {
|
||||
return nil
|
||||
}
|
||||
if pl.Evaluator.IsPodRunningPreemption(p.GetUID()) {
|
||||
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "waiting for the preemption for this pod to be finished")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EventsToRegister returns the possible events that may make a Pod
|
||||
// failed by this plugin schedulable.
|
||||
func (pl *DefaultPreemption) EventsToRegister(_ context.Context) ([]framework.ClusterEventWithHint, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user