From 98ef76c164c2553e984da7e05bc82c4697d8b4ac Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Thu, 21 Aug 2014 16:24:18 -0700 Subject: [PATCH] Remove references to scheduler from pod storage. --- pkg/master/master.go | 6 ------ pkg/registry/pod/storage.go | 15 +-------------- pkg/registry/pod/storage_test.go | 16 ++++------------ 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/pkg/master/master.go b/pkg/master/master.go index 174d70b0781..626291c6185 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -17,7 +17,6 @@ limitations under the License. package master import ( - "math/rand" "net/http" "time" @@ -32,7 +31,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service" - "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" goetcd "github.com/coreos/go-etcd/etcd" @@ -111,16 +109,12 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf endpoints := endpoint.NewEndpointController(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{ "pods": pod.NewRegistryStorage(&pod.RegistryStorageConfig{ CloudProvider: cloud, - MinionLister: m.minionRegistry, PodCache: podCache, PodInfoGetter: podInfoGetter, Registry: m.podRegistry, - Scheduler: s, }), "replicationControllers": controller.NewRegistryStorage(m.controllerRegistry, m.podRegistry), "services": service.NewRegistryStorage(m.serviceRegistry, cloud, m.minionRegistry), diff --git a/pkg/registry/pod/storage.go b/pkg/registry/pod/storage.go index 0433599d1d6..2f9410c8d8c 100644 --- a/pkg/registry/pod/storage.go +++ b/pkg/registry/pod/storage.go @@ -27,7 +27,6 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" - "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/watch" @@ -39,33 +38,27 @@ import ( type RegistryStorage struct { cloudProvider cloudprovider.Interface mu sync.Mutex - minionLister scheduler.MinionLister podCache client.PodInfoGetter podInfoGetter client.PodInfoGetter podPollPeriod time.Duration registry Registry - scheduler scheduler.Scheduler } type RegistryStorageConfig struct { CloudProvider cloudprovider.Interface - MinionLister scheduler.MinionLister PodCache client.PodInfoGetter PodInfoGetter client.PodInfoGetter Registry Registry - Scheduler scheduler.Scheduler } // NewRegistryStorage returns a new RegistryStorage. func NewRegistryStorage(config *RegistryStorageConfig) apiserver.RESTStorage { return &RegistryStorage{ cloudProvider: config.CloudProvider, - minionLister: config.MinionLister, podCache: config.PodCache, podInfoGetter: config.PodInfoGetter, podPollPeriod: time.Second * 10, registry: config.Registry, - scheduler: config.Scheduler, } } @@ -82,7 +75,7 @@ func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { pod.CreationTimestamp = util.Now() return apiserver.MakeAsync(func() (interface{}, error) { - if err := rs.scheduleAndCreatePod(*pod); err != nil { + if err := rs.registry.CreatePod(*pod); err != nil { return nil, err } return rs.registry.GetPod(pod.ID) @@ -245,12 +238,6 @@ func getPodStatus(pod *api.Pod) api.PodStatus { } } -func (rs *RegistryStorage) scheduleAndCreatePod(pod api.Pod) error { - rs.mu.Lock() - defer rs.mu.Unlock() - return rs.registry.CreatePod(pod) -} - func (rs *RegistryStorage) waitForPodRunning(pod api.Pod) (interface{}, error) { for { podObj, err := rs.Get(pod.ID) diff --git a/pkg/registry/pod/storage_test.go b/pkg/registry/pod/storage_test.go index 70821c526b5..24ad2c46e95 100644 --- a/pkg/registry/pod/storage_test.go +++ b/pkg/registry/pod/storage_test.go @@ -25,9 +25,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/fake" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" - "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/minion" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest" - "github.com/GoogleCloudPlatform/kubernetes/pkg/scheduler" "github.com/fsouza/go-dockerclient" ) @@ -58,8 +56,7 @@ func TestCreatePodRegistryError(t *testing.T) { podRegistry := registrytest.NewPodRegistry(nil) podRegistry.Err = fmt.Errorf("test error") storage := RegistryStorage{ - scheduler: ®istrytest.Scheduler{}, - registry: podRegistry, + registry: podRegistry, } desiredState := api.PodState{ Manifest: api.ContainerManifest{ @@ -78,8 +75,7 @@ func TestCreatePodSetsIds(t *testing.T) { podRegistry := registrytest.NewPodRegistry(nil) podRegistry.Err = fmt.Errorf("test error") storage := RegistryStorage{ - scheduler: ®istrytest.Scheduler{Machine: "test"}, - registry: podRegistry, + registry: podRegistry, } desiredState := api.PodState{ Manifest: api.ContainerManifest{ @@ -327,8 +323,7 @@ func TestPodStorageValidatesCreate(t *testing.T) { podRegistry := registrytest.NewPodRegistry(nil) podRegistry.Err = fmt.Errorf("test error") storage := RegistryStorage{ - scheduler: ®istrytest.Scheduler{Machine: "test"}, - registry: podRegistry, + registry: podRegistry, } pod := &api.Pod{} c, err := storage.Create(pod) @@ -344,8 +339,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) { podRegistry := registrytest.NewPodRegistry(nil) podRegistry.Err = fmt.Errorf("test error") storage := RegistryStorage{ - scheduler: ®istrytest.Scheduler{Machine: "test"}, - registry: podRegistry, + registry: podRegistry, } pod := &api.Pod{} c, err := storage.Update(pod) @@ -368,8 +362,6 @@ func TestCreatePod(t *testing.T) { storage := RegistryStorage{ registry: podRegistry, podPollPeriod: time.Millisecond * 100, - scheduler: scheduler.NewRoundRobinScheduler(), - minionLister: minion.NewRegistry([]string{"machine"}), } desiredState := api.PodState{ Manifest: api.ContainerManifest{