mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Prevent scheduler from crashing infinitely if apiserver is unreachable
This commit is contained in:
parent
65b4247892
commit
16641757ef
@ -58,7 +58,10 @@ func main() {
|
|||||||
go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil)
|
go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil)
|
||||||
|
|
||||||
configFactory := &factory.ConfigFactory{Client: kubeClient}
|
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 := scheduler.New(config)
|
||||||
s.Run()
|
s.Run()
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ type ConfigFactory struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create creates a scheduler and all support functions.
|
// 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.
|
// Watch and queue pods that need scheduling.
|
||||||
podQueue := cache.NewFIFO()
|
podQueue := cache.NewFIFO()
|
||||||
cache.NewReflector(factory.createUnassignedPodLW(), &api.Pod{}, podQueue).Run()
|
cache.NewReflector(factory.createUnassignedPodLW(), &api.Pod{}, podQueue).Run()
|
||||||
@ -66,8 +66,7 @@ func (factory *ConfigFactory) Create() *scheduler.Config {
|
|||||||
|
|
||||||
nodes, err := factory.Client.ListMinions()
|
nodes, err := factory.Client.ListMinions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("failed to obtain minion information, aborting")
|
return nil, err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
algo := algorithm.NewGenericScheduler(
|
algo := algorithm.NewGenericScheduler(
|
||||||
[]algorithm.FitPredicate{
|
[]algorithm.FitPredicate{
|
||||||
@ -98,7 +97,7 @@ func (factory *ConfigFactory) Create() *scheduler.Config {
|
|||||||
return pod
|
return pod
|
||||||
},
|
},
|
||||||
Error: factory.makeDefaultErrorFunc(&podBackoff, podQueue),
|
Error: factory.makeDefaultErrorFunc(&podBackoff, podQueue),
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type listWatch struct {
|
type listWatch struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user