Scheduler PostFilter API

This commit is contained in:
Wei Huang 2020-05-28 14:20:56 -07:00
parent 1d566466cf
commit 1837b49554
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005
4 changed files with 55 additions and 41 deletions

View File

@ -190,6 +190,9 @@ type Plugins struct {
// Filter is a list of plugins that should be invoked when filtering out nodes that cannot run the Pod.
Filter *PluginSet
// PostFilter is a list of plugins that are invoked after filtering phase, no matter whether filtering succeeds or not.
PostFilter *PluginSet
// PreScore is a list of plugins that are invoked before scoring.
PreScore *PluginSet
@ -284,6 +287,7 @@ func (p *Plugins) Append(src *Plugins) {
p.QueueSort = appendPluginSet(p.QueueSort, src.QueueSort)
p.PreFilter = appendPluginSet(p.PreFilter, src.PreFilter)
p.Filter = appendPluginSet(p.Filter, src.Filter)
p.PostFilter = appendPluginSet(p.PostFilter, src.PostFilter)
p.PreScore = appendPluginSet(p.PreScore, src.PreScore)
p.Score = appendPluginSet(p.Score, src.Score)
p.Reserve = appendPluginSet(p.Reserve, src.Reserve)
@ -303,6 +307,7 @@ func (p *Plugins) Apply(customPlugins *Plugins) {
p.QueueSort = mergePluginSets(p.QueueSort, customPlugins.QueueSort)
p.PreFilter = mergePluginSets(p.PreFilter, customPlugins.PreFilter)
p.Filter = mergePluginSets(p.Filter, customPlugins.Filter)
p.PostFilter = mergePluginSets(p.PostFilter, customPlugins.PostFilter)
p.PreScore = mergePluginSets(p.PreScore, customPlugins.PreScore)
p.Score = mergePluginSets(p.Score, customPlugins.Score)
p.Reserve = mergePluginSets(p.Reserve, customPlugins.Reserve)

View File

@ -56,6 +56,7 @@ func TestPluginsAppend(t *testing.T) {
{Name: "CustomPlugin"},
},
},
PostFilter: &PluginSet{},
PreScore: &PluginSet{},
Score: &PluginSet{},
Reserve: &PluginSet{},
@ -117,6 +118,7 @@ func TestPluginsApply(t *testing.T) {
{Name: "CustomPlugin"},
},
},
PostFilter: &PluginSet{Enabled: []Plugin{}},
PreScore: &PluginSet{Enabled: []Plugin{}},
Score: &PluginSet{Enabled: []Plugin{}},
Reserve: &PluginSet{Enabled: []Plugin{}},
@ -158,6 +160,7 @@ func TestPluginsApply(t *testing.T) {
{Name: "DefaultPlugin2"},
},
},
PostFilter: &PluginSet{Enabled: []Plugin{}},
PreScore: &PluginSet{Enabled: []Plugin{}},
Score: &PluginSet{Enabled: []Plugin{}},
Reserve: &PluginSet{Enabled: []Plugin{}},
@ -200,6 +203,7 @@ func TestPluginsApply(t *testing.T) {
{Name: "DefaultPlugin2"},
},
},
PostFilter: &PluginSet{Enabled: []Plugin{}},
PreScore: &PluginSet{Enabled: []Plugin{}},
Score: &PluginSet{Enabled: []Plugin{}},
Reserve: &PluginSet{Enabled: []Plugin{}},
@ -240,6 +244,7 @@ func TestPluginsApply(t *testing.T) {
{Name: "DefaultPlugin1"},
},
},
PostFilter: &PluginSet{Enabled: []Plugin{}},
PreScore: &PluginSet{Enabled: []Plugin{}},
Score: &PluginSet{Enabled: []Plugin{}},
Reserve: &PluginSet{Enabled: []Plugin{}},

View File

@ -102,6 +102,7 @@ func TestRegisterConfigProducers(t *testing.T) {
{Name: testFilterName2},
},
},
PostFilter: &config.PluginSet{},
PreScore: &config.PluginSet{},
Score: &config.PluginSet{
Enabled: []config.Plugin{

View File

@ -173,6 +173,9 @@ type Plugins struct {
// Filter is a list of plugins that should be invoked when filtering out nodes that cannot run the Pod.
Filter *PluginSet `json:"filter,omitempty"`
// PostFilter is a list of plugins that are invoked after filtering phase, no matter whether filtering succeeds or not.
PostFilter *PluginSet `json:"postFilter,omitempty"`
// PreScore is a list of plugins that are invoked before scoring.
PreScore *PluginSet `json:"preScore,omitempty"`