feature(scheduler): won't run Score if PreScore returned a Skip status (#115652)
* allow preScore to return skip status to skip running the corresponding score extension * add test case for all skipped * add test case for select host * update plugin status * skip score when all plugins are skipped * update
This commit is contained in:

committed by
GitHub

parent
436ca94642
commit
f5a69ffda9
@@ -245,3 +245,38 @@ func NewFakePermitPlugin(status *framework.Status, timeout time.Duration) framew
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
type FakePreScoreAndScorePlugin struct {
|
||||
name string
|
||||
score int64
|
||||
preScoreStatus *framework.Status
|
||||
scoreStatus *framework.Status
|
||||
}
|
||||
|
||||
// Name returns name of the plugin.
|
||||
func (pl *FakePreScoreAndScorePlugin) Name() string {
|
||||
return pl.name
|
||||
}
|
||||
|
||||
func (pl *FakePreScoreAndScorePlugin) Score(ctx context.Context, state *framework.CycleState, p *v1.Pod, nodeName string) (int64, *framework.Status) {
|
||||
return pl.score, pl.scoreStatus
|
||||
}
|
||||
|
||||
func (pl *FakePreScoreAndScorePlugin) ScoreExtensions() framework.ScoreExtensions {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pl *FakePreScoreAndScorePlugin) PreScore(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodes []*v1.Node) *framework.Status {
|
||||
return pl.preScoreStatus
|
||||
}
|
||||
|
||||
func NewFakePreScoreAndScorePlugin(name string, score int64, preScoreStatus, scoreStatus *framework.Status) frameworkruntime.PluginFactory {
|
||||
return func(_ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
|
||||
return &FakePreScoreAndScorePlugin{
|
||||
name: name,
|
||||
score: score,
|
||||
preScoreStatus: preScoreStatus,
|
||||
scoreStatus: scoreStatus,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user