Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: removed BoundPodFactory. #5429

Merged
merged 1 commit into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter)

// init initializes master.
func (m *Master) init(c *Config) {

boundPodFactory := &pod.BasicBoundPodFactory{}
podStorage, bindingStorage, podStatusStorage := podetcd.NewREST(c.EtcdHelper, boundPodFactory)
podStorage, bindingStorage, podStatusStorage := podetcd.NewREST(c.EtcdHelper)
podRegistry := pod.NewRegistry(podStorage)

eventRegistry := event.NewEtcdRegistry(c.EtcdHelper, uint64(c.EventTTL.Seconds()))
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {

func NewTestEtcdRegistryWithPods(client tools.EtcdClient) *Registry {
helper := tools.EtcdHelper{client, latest.Codec, tools.RuntimeVersionAdapter{latest.ResourceVersioner}}
podStorage, _, _ := podetcd.NewREST(helper, nil)
podStorage, _, _ := podetcd.NewREST(helper)
registry := NewRegistry(helper, pod.NewRegistry(podStorage))
return registry
}
Expand Down
38 changes: 0 additions & 38 deletions pkg/registry/pod/bound_pod_factory.go

This file was deleted.

53 changes: 0 additions & 53 deletions pkg/registry/pod/bound_pod_factory_test.go

This file was deleted.

9 changes: 4 additions & 5 deletions pkg/registry/pod/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type REST struct {
}

// NewREST returns a RESTStorage object that will work against pods.
func NewREST(h tools.EtcdHelper, factory pod.BoundPodFactory) (*REST, *BindingREST, *StatusREST) {
func NewREST(h tools.EtcdHelper) (*REST, *BindingREST, *StatusREST) {
prefix := "/registry/pods"
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Pod{} },
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewREST(h tools.EtcdHelper, factory pod.BoundPodFactory) (*REST, *BindingRE

statusStore.UpdateStrategy = pod.StatusStrategy

return &REST{store: store}, &BindingREST{store: store, factory: factory}, &StatusREST{store: &statusStore}
return &REST{store: store}, &BindingREST{store: store}, &StatusREST{store: &statusStore}
}

// WithPodStatus returns a rest object that decorates returned responses with extra
Expand Down Expand Up @@ -130,8 +130,7 @@ func (r *REST) ResourceLocation(ctx api.Context, name string) (string, error) {

// BindingREST implements the REST endpoint for binding pods to nodes when etcd is in use.
type BindingREST struct {
store *etcdgeneric.Etcd
factory pod.BoundPodFactory
store *etcdgeneric.Etcd
}

func (r *BindingREST) New() runtime.Object {
Expand Down Expand Up @@ -167,7 +166,7 @@ func (r *BindingREST) setPodHostTo(ctx api.Context, podID, oldMachine, machine s
return nil, fmt.Errorf("unexpected object: %#v", obj)
}
if pod.Spec.Host != oldMachine || pod.Status.Host != oldMachine {
return nil, fmt.Errorf("pod %v is already assigned to host %v or %v", pod.Name, pod.Spec.Host, pod.Status.Host)
return nil, fmt.Errorf("pod %v is already assigned to host %q or %q", pod.Name, pod.Spec.Host, pod.Status.Host)
}
pod.Spec.Host = machine
pod.Status.Host = machine
Expand Down
36 changes: 18 additions & 18 deletions pkg/registry/pod/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func newHelper(t *testing.T) (*tools.FakeEtcdClient, tools.EtcdHelper) {

func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *tools.FakeEtcdClient, tools.EtcdHelper) {
fakeEtcdClient, h := newHelper(t)
storage, bindingStorage, statusStorage := NewREST(h, &pod.BasicBoundPodFactory{})
storage, bindingStorage, statusStorage := NewREST(h)
storage = storage.WithPodStatus(&fakeCache{statusToReturn: &api.PodStatus{}})
return storage, bindingStorage, statusStorage, fakeEtcdClient, h
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestStorage(t *testing.T) {

func TestCreate(t *testing.T) {
fakeEtcdClient, helper := newHelper(t)
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
storage = storage.WithPodStatus(cache)
test := resttest.New(t, storage, fakeEtcdClient.SetError)
Expand Down Expand Up @@ -142,7 +142,7 @@ func expectPod(t *testing.T, out runtime.Object) (*api.Pod, bool) {
func TestCreateRegistryError(t *testing.T) {
fakeEtcdClient, helper := newHelper(t)
fakeEtcdClient.Err = fmt.Errorf("test error")
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)

pod := validNewPod()
_, err := storage.Create(api.NewDefaultContext(), pod)
Expand All @@ -153,7 +153,7 @@ func TestCreateRegistryError(t *testing.T) {

func TestCreateSetsFields(t *testing.T) {
fakeEtcdClient, helper := newHelper(t)
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
storage = storage.WithPodStatus(cache)
pod := validNewPod()
Expand All @@ -177,7 +177,7 @@ func TestCreateSetsFields(t *testing.T) {
func TestListError(t *testing.T) {
fakeEtcdClient, helper := newHelper(t)
fakeEtcdClient.Err = fmt.Errorf("test error")
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{}
storage = storage.WithPodStatus(cache)
pods, err := storage.List(api.NewDefaultContext(), labels.Everything(), fields.Everything())
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestListCacheError(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{errorToReturn: client.ErrPodInfoNotAvailable}
storage = storage.WithPodStatus(cache)

Expand All @@ -230,7 +230,7 @@ func TestListEmptyPodList(t *testing.T) {
E: fakeEtcdClient.NewError(tools.EtcdErrorCodeNotFound),
}

storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{}
storage = storage.WithPodStatus(cache)
pods, err := storage.List(api.NewContext(), labels.Everything(), fields.Everything())
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestListPodList(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -319,7 +319,7 @@ func TestListPodListSelection(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -386,7 +386,7 @@ func TestListPodListSelection(t *testing.T) {
}

func TestPodDecode(t *testing.T) {
storage, _, _ := NewREST(tools.EtcdHelper{}, nil)
storage, _, _ := NewREST(tools.EtcdHelper{})
expected := validNewPod()
body, err := latest.Codec.Encode(expected)
if err != nil {
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestGet(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{Phase: api.PodRunning}}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -443,7 +443,7 @@ func TestGetCacheError(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{errorToReturn: client.ErrPodInfoNotAvailable}
storage = storage.WithPodStatus(cache)

Expand All @@ -463,7 +463,7 @@ func TestGetCacheError(t *testing.T) {
func TestPodStorageValidatesCreate(t *testing.T) {
fakeEtcdClient, helper := newHelper(t)
fakeEtcdClient.Err = fmt.Errorf("test error")
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
storage = storage.WithPodStatus(cache)

Expand All @@ -483,7 +483,7 @@ func TestPodStorageValidatesCreate(t *testing.T) {
// TODO: remove, this is covered by RESTTest.TestCreate
func TestCreatePod(t *testing.T) {
_, helper := newHelper(t)
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
storage = storage.WithPodStatus(cache)

Expand All @@ -507,7 +507,7 @@ func TestCreatePod(t *testing.T) {
// TODO: remove, this is covered by RESTTest.TestCreate
func TestCreateWithConflictingNamespace(t *testing.T) {
_, helper := newHelper(t)
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -538,7 +538,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -650,7 +650,7 @@ func TestResourceLocation(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{PodIP: expectedIP}}
storage = storage.WithPodStatus(cache)

Expand Down Expand Up @@ -684,7 +684,7 @@ func TestDeletePod(t *testing.T) {
},
},
}
storage, _, _ := NewREST(helper, nil)
storage, _, _ := NewREST(helper)
cache := &fakeCache{statusToReturn: &api.PodStatus{}}
storage = storage.WithPodStatus(cache)

Expand Down