Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent scheduler from crashing infinitely if apiserver is unreachable #1613

Merged
merged 1 commit into from
Oct 7, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugin/cmd/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func main() {
go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil)

configFactory := &factory.ConfigFactory{Client: kubeClient}
config := configFactory.Create()
config, err := configFactory.Create()
if err != nil {
glog.Fatalf("Can't create scheduler config: %v", err)
}
s := scheduler.New(config)
s.Run()

Expand Down
7 changes: 3 additions & 4 deletions plugin/pkg/scheduler/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ConfigFactory struct {
}

// Create creates a scheduler and all support functions.
func (factory *ConfigFactory) Create() *scheduler.Config {
func (factory *ConfigFactory) Create() (*scheduler.Config, error) {
// Watch and queue pods that need scheduling.
podQueue := cache.NewFIFO()
cache.NewReflector(factory.createUnassignedPodLW(), &api.Pod{}, podQueue).Run()
Expand All @@ -66,8 +66,7 @@ func (factory *ConfigFactory) Create() *scheduler.Config {

nodes, err := factory.Client.ListMinions()
Copy link
Member

Choose a reason for hiding this comment

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

This is a bug in the scheduler-- @brendandburns did you add this call to List? It should NOT be listing at setup time, only at run time. Nodes can change at runtime!!

if err != nil {
glog.Errorf("failed to obtain minion information, aborting")
return nil
return nil, err
}
algo := algorithm.NewGenericScheduler(
[]algorithm.FitPredicate{
Expand Down Expand Up @@ -98,7 +97,7 @@ func (factory *ConfigFactory) Create() *scheduler.Config {
return pod
},
Error: factory.makeDefaultErrorFunc(&podBackoff, podQueue),
}
}, nil
}

type listWatch struct {
Expand Down