dedupe registry.MakeEndpointController init

This commit is contained in:
Kouhei Ueno
2014-08-05 05:09:49 +09:00
parent a06d6726d4
commit afa686ccc8

View File

@@ -110,6 +110,10 @@ func minionRegistryMaker(c *Config) registry.MinionRegistry {
func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInfoGetter) {
podCache := NewPodCache(podInfoGetter, m.podRegistry, time.Second*30)
go podCache.Loop()
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.client)
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
s := scheduler.NewRandomFitScheduler(m.podRegistry, random)
m.storage = map[string]apiserver.RESTStorage{
@@ -122,9 +126,6 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
// Run begins serving the Kubernetes API. It never returns.
func (m *Master) Run(myAddress, apiPrefix string) error {
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.client)
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
s := &http.Server{
Addr: myAddress,
Handler: apiserver.New(m.storage, apiPrefix),
@@ -139,8 +140,5 @@ func (m *Master) Run(myAddress, apiPrefix string) error {
// Instead of calling Run, you can call this function to get a handler for your own server.
// It is intended for testing. Only call once.
func (m *Master) ConstructHandler(apiPrefix string) http.Handler {
endpoints := registry.MakeEndpointController(m.serviceRegistry, m.client)
go util.Forever(func() { endpoints.SyncServiceEndpoints() }, time.Second*10)
return apiserver.New(m.storage, apiPrefix)
}