From 938d9e811bd150df025a3fcf036a439ef06ee16a Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Tue, 15 Jul 2014 19:47:40 +0900 Subject: [PATCH] don't reuse random --- pkg/master/master.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/master/master.go b/pkg/master/master.go index e12fc7f28ec..1296ee500f0 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -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.