Merge pull request #460 from nyaxt/remove_random

Don't keep rand.Rand inside Master
This commit is contained in:
brendandburns 2014-07-16 09:54:57 -07:00
commit 18c4f42c5c

View File

@ -37,10 +37,7 @@ type Master struct {
controllerRegistry registry.ControllerRegistry
serviceRegistry registry.ServiceRegistry
minionRegistry registry.MinionRegistry
// TODO: don't reuse non-threadsafe objects.
random *rand.Rand
storage map[string]apiserver.RESTStorage
storage map[string]apiserver.RESTStorage
}
// NewMemoryServer returns a new instance of Master backed with memory (not etcd).
@ -81,17 +78,16 @@ func minionRegistryMaker(minions []string, cloud cloudprovider.Interface, minion
}
func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInfoGetter) {
m.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
podCache := NewPodCache(podInfoGetter, m.podRegistry, time.Second*30)
go podCache.Loop()
s := scheduler.NewRandomFitScheduler(m.podRegistry, m.random)
random := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
s := scheduler.NewRandomFitScheduler(m.podRegistry, random)
m.storage = map[string]apiserver.RESTStorage{
"pods": registry.MakePodRegistryStorage(m.podRegistry, podInfoGetter, s, m.minionRegistry, cloud, podCache),
"replicationControllers": registry.NewControllerRegistryStorage(m.controllerRegistry, m.podRegistry),
"services": registry.MakeServiceRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry),
"minions": registry.MakeMinionRegistryStorage(m.minionRegistry),
}
}
// Run begins serving the Kubernetes API. It never returns.