Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Support Plugin Arguments #639

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/scheduler/conf/scheduler_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass the arguments to plugins: update plugin's New to New(args map[string]string).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made those changes

}
2 changes: 1 addition & 1 deletion pkg/scheduler/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/framework/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/plugins/conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions pkg/scheduler/plugins/drf/drf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/plugins/gang/gang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/plugins/nodeorder/nodeorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/plugins/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/plugins/priority/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions pkg/scheduler/plugins/proportion/proportion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
}

Expand Down