Skip to content

Commit

Permalink
Merge pull request kubernetes#3544 from mikedanese/provider-run-opt
Browse files Browse the repository at this point in the history
Configure scheduler algorithm provider with cli option
  • Loading branch information
davidopp committed Jan 16, 2015
2 parents 311dada + e3da5e1 commit a3e057d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions plugin/cmd/kube-scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ import (
)

var (
port = flag.Int("port", ports.SchedulerPort, "The port that the scheduler's http service runs on")
address = util.IP(net.ParseIP("127.0.0.1"))
clientConfig = &client.Config{}
port = flag.Int("port", ports.SchedulerPort, "The port that the scheduler's http service runs on")
address = util.IP(net.ParseIP("127.0.0.1"))
clientConfig = &client.Config{}
algorithmProvider = flag.String("algorithm_provider", factory.DefaultProvider, "The scheduling algorithm provider to use")
)

func init() {
Expand All @@ -64,7 +65,7 @@ func main() {
go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil)

configFactory := factory.NewConfigFactory(kubeClient)
config, err := configFactory.Create()
config, err := createConfig(configFactory)
if err != nil {
glog.Fatalf("Failed to create scheduler configuration: %v", err)
}
Expand All @@ -73,3 +74,12 @@ func main() {

select {}
}

func createConfig(configFactory *factory.ConfigFactory) (*scheduler.Config, error) {
// check of algorithm provider is registered and fail fast
_, err := factory.GetAlgorithmProvider(*algorithmProvider)
if err != nil {
return nil, err
}
return configFactory.CreateFromProvider(*algorithmProvider)
}
2 changes: 1 addition & 1 deletion plugin/pkg/scheduler/factory/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
)

const (
DefaultProvider = "default"
DefaultProvider = "DefaultProvider"
)

type AlgorithmProviderConfig struct {
Expand Down

0 comments on commit a3e057d

Please sign in to comment.