diff --git a/pkg/scheduler/conf/scheduler_conf.go b/pkg/scheduler/conf/scheduler_conf.go index fdcbdff90..84124c753 100644 --- a/pkg/scheduler/conf/scheduler_conf.go +++ b/pkg/scheduler/conf/scheduler_conf.go @@ -49,4 +49,6 @@ type PluginOption struct { PredicateDisabled bool `yaml:"disablePredicate"` // NodeOrderDisabled defines whether NodeOrderFn is disabled NodeOrderDisabled bool `yaml:"disableNodeOrder"` + // Arguments defines the different arguments that can be given to different plugins + Arguments map[string]string `yaml:"arguments"` } diff --git a/pkg/scheduler/framework/framework.go b/pkg/scheduler/framework/framework.go index a25f1c6e0..f0affdf61 100644 --- a/pkg/scheduler/framework/framework.go +++ b/pkg/scheduler/framework/framework.go @@ -35,7 +35,7 @@ func OpenSession(cache cache.Cache, tiers []conf.Tier) *Session { if pb, found := GetPluginBuilder(plugin.Name); !found { glog.Errorf("Failed to get plugin %s.", plugin.Name) } else { - plugin := pb() + plugin := pb(plugin.Arguments) ssn.plugins[plugin.Name()] = plugin } } diff --git a/pkg/scheduler/framework/plugins.go b/pkg/scheduler/framework/plugins.go index 3b5a897f3..ee0ecf057 100644 --- a/pkg/scheduler/framework/plugins.go +++ b/pkg/scheduler/framework/plugins.go @@ -20,12 +20,12 @@ import "sync" var pluginMutex sync.Mutex -type PluginBuilder func() Plugin +type PluginBuilder func(map[string]string) Plugin // Plugin management var pluginBuilders = map[string]PluginBuilder{} -func RegisterPluginBuilder(name string, pc func() Plugin) { +func RegisterPluginBuilder(name string, pc func(map[string]string) Plugin) { pluginMutex.Lock() defer pluginMutex.Unlock() diff --git a/pkg/scheduler/plugins/conformance/conformance.go b/pkg/scheduler/plugins/conformance/conformance.go index 779c3f79a..b35ebe903 100644 --- a/pkg/scheduler/plugins/conformance/conformance.go +++ b/pkg/scheduler/plugins/conformance/conformance.go @@ -25,10 +25,12 @@ import ( ) type conformancePlugin struct { + // Arguments given for the plugin + pluginArguments map[string]string } -func New() framework.Plugin { - return &conformancePlugin{} +func New(arguments map[string]string) framework.Plugin { + return &conformancePlugin{pluginArguments: arguments} } func (pp *conformancePlugin) Name() string { diff --git a/pkg/scheduler/plugins/drf/drf.go b/pkg/scheduler/plugins/drf/drf.go index 246c23e6f..13137fdee 100644 --- a/pkg/scheduler/plugins/drf/drf.go +++ b/pkg/scheduler/plugins/drf/drf.go @@ -39,12 +39,16 @@ type drfPlugin struct { // Key is Job ID jobOpts map[api.JobID]*drfAttr + + // Arguments given for the plugin + pluginArguments map[string]string } -func New() framework.Plugin { +func New(arguments map[string]string) framework.Plugin { return &drfPlugin{ - totalResource: api.EmptyResource(), - jobOpts: map[api.JobID]*drfAttr{}, + totalResource: api.EmptyResource(), + jobOpts: map[api.JobID]*drfAttr{}, + pluginArguments: arguments, } } diff --git a/pkg/scheduler/plugins/gang/gang.go b/pkg/scheduler/plugins/gang/gang.go index 7c85f9aef..239c5155d 100644 --- a/pkg/scheduler/plugins/gang/gang.go +++ b/pkg/scheduler/plugins/gang/gang.go @@ -31,10 +31,12 @@ import ( ) type gangPlugin struct { + // Arguments given for the plugin + pluginArguments map[string]string } -func New() framework.Plugin { - return &gangPlugin{} +func New(arguments map[string]string) framework.Plugin { + return &gangPlugin{pluginArguments: arguments} } func (gp *gangPlugin) Name() string { diff --git a/pkg/scheduler/plugins/nodeorder/nodeorder.go b/pkg/scheduler/plugins/nodeorder/nodeorder.go index 58b481e6c..32fd9d646 100644 --- a/pkg/scheduler/plugins/nodeorder/nodeorder.go +++ b/pkg/scheduler/plugins/nodeorder/nodeorder.go @@ -33,6 +33,8 @@ import ( ) type nodeOrderPlugin struct { + // Arguments given for the plugin + pluginArguments map[string]string } func getInterPodAffinityScore(name string, interPodAffinityScore schedulerapi.HostPriorityList) int { @@ -145,8 +147,8 @@ func (nl *nodeLister) List() ([]*v1.Node, error) { } //New function returns prioritizePlugin object -func New() framework.Plugin { - return &nodeOrderPlugin{} +func New(aruguments map[string]string) framework.Plugin { + return &nodeOrderPlugin{pluginArguments: aruguments} } func (pp *nodeOrderPlugin) Name() string { diff --git a/pkg/scheduler/plugins/predicates/predicates.go b/pkg/scheduler/plugins/predicates/predicates.go index d19090423..0c2cd5c5b 100644 --- a/pkg/scheduler/plugins/predicates/predicates.go +++ b/pkg/scheduler/plugins/predicates/predicates.go @@ -32,10 +32,12 @@ import ( ) type predicatesPlugin struct { + // Arguments given for the plugin + pluginArguments map[string]string } -func New() framework.Plugin { - return &predicatesPlugin{} +func New(arguments map[string]string) framework.Plugin { + return &predicatesPlugin{pluginArguments: arguments} } func (pp *predicatesPlugin) Name() string { diff --git a/pkg/scheduler/plugins/priority/priority.go b/pkg/scheduler/plugins/priority/priority.go index edb4ac475..08df753f7 100644 --- a/pkg/scheduler/plugins/priority/priority.go +++ b/pkg/scheduler/plugins/priority/priority.go @@ -23,10 +23,12 @@ import ( ) type priorityPlugin struct { + // Arguments given for the plugin + pluginArguments map[string]string } -func New() framework.Plugin { - return &priorityPlugin{} +func New(arguments map[string]string) framework.Plugin { + return &priorityPlugin{pluginArguments: arguments} } func (pp *priorityPlugin) Name() string { diff --git a/pkg/scheduler/plugins/proportion/proportion.go b/pkg/scheduler/plugins/proportion/proportion.go index 582adf3f4..72eaa1e34 100644 --- a/pkg/scheduler/plugins/proportion/proportion.go +++ b/pkg/scheduler/plugins/proportion/proportion.go @@ -27,6 +27,8 @@ import ( type proportionPlugin struct { totalResource *api.Resource queueOpts map[api.QueueID]*queueAttr + // Arguments given for the plugin + pluginArguments map[string]string } type queueAttr struct { @@ -40,10 +42,11 @@ type queueAttr struct { request *api.Resource } -func New() framework.Plugin { +func New(arguments map[string]string) framework.Plugin { return &proportionPlugin{ - totalResource: api.EmptyResource(), - queueOpts: map[api.QueueID]*queueAttr{}, + totalResource: api.EmptyResource(), + queueOpts: map[api.QueueID]*queueAttr{}, + pluginArguments: arguments, } }