From 26cff8b9bf27e40ded9d85cb44bd199efbdfc69f Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 14 Oct 2014 17:31:11 -0400 Subject: [PATCH] Rename the etcd path for pods to be /registry/nodes/<>/boundpods --- pkg/kubelet/config/etcd.go | 6 +----- pkg/registry/etcd/etcd.go | 2 +- pkg/registry/etcd/etcd_test.go | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pkg/kubelet/config/etcd.go b/pkg/kubelet/config/etcd.go index d53e787b555..aae9d07d2d6 100644 --- a/pkg/kubelet/config/etcd.go +++ b/pkg/kubelet/config/etcd.go @@ -34,7 +34,7 @@ import ( ) func EtcdKeyForHost(hostname string) string { - return path.Join("/", "registry", "hosts", hostname, "kubelet") + return path.Join("/", "registry", "nodes", hostname, "boundpods") } type SourceEtcd struct { @@ -111,7 +111,3 @@ func eventToPods(ev watch.Event) ([]api.BoundPod, error) { return pods, nil } - -func makeContainerKey(machine string) string { - return "/registry/hosts/" + machine + "/kubelet" -} diff --git a/pkg/registry/etcd/etcd.go b/pkg/registry/etcd/etcd.go index 5268b1b5004..001ba16273e 100644 --- a/pkg/registry/etcd/etcd.go +++ b/pkg/registry/etcd/etcd.go @@ -177,7 +177,7 @@ func (r *Registry) GetPod(ctx api.Context, id string) (*api.Pod, error) { } func makeContainerKey(machine string) string { - return "/registry/hosts/" + machine + "/kubelet" + return "/registry/nodes/" + machine + "/boundpods" } // CreatePod creates a pod based on a specification. diff --git a/pkg/registry/etcd/etcd_test.go b/pkg/registry/etcd/etcd_test.go index 43da36a0005..51c787646b8 100644 --- a/pkg/registry/etcd/etcd_test.go +++ b/pkg/registry/etcd/etcd_test.go @@ -160,7 +160,7 @@ func TestEtcdCreatePod(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{}), 0) + fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{}), 0) registry := NewTestEtcdRegistry(fakeClient) err := registry.CreatePod(ctx, &api.Pod{ TypeMeta: api.TypeMeta{ @@ -200,7 +200,7 @@ func TestEtcdCreatePod(t *testing.T) { t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) } var boundPods api.BoundPods - resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) + resp, err = fakeClient.Get("/registry/nodes/machine/boundpods", false, false) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -268,7 +268,7 @@ func TestEtcdCreatePodWithContainersError(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{ + fakeClient.Data["/registry/nodes/machine/boundpods"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: nil, }, @@ -310,7 +310,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Data["/registry/hosts/machine/kubelet"] = tools.EtcdResponseWithError{ + fakeClient.Data["/registry/nodes/machine/boundpods"] = tools.EtcdResponseWithError{ R: &etcd.Response{ Node: nil, }, @@ -356,7 +356,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) } var boundPods api.BoundPods - resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) + resp, err = fakeClient.Get("/registry/nodes/machine/boundpods", false, false) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -378,7 +378,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { }, E: tools.EtcdErrorNotFound, } - fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ + fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ Items: []api.BoundPod{ {TypeMeta: api.TypeMeta{ID: "bar"}}, }, @@ -423,7 +423,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { t.Errorf("Unexpected pod: %#v %s", pod, resp.Node.Value) } var boundPods api.BoundPods - resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) + resp, err = fakeClient.Get("/registry/nodes/machine/boundpods", false, false) if err != nil { t.Errorf("unexpected error: %v", err) } @@ -511,7 +511,7 @@ func TestEtcdUpdatePodScheduled(t *testing.T) { }, }), 1) - contKey := "/registry/hosts/machine/kubelet" + contKey := "/registry/nodes/machine/boundpods" fakeClient.Set(contKey, runtime.EncodeOrDie(latest.Codec, &api.ContainerManifestList{ Items: []api.ContainerManifest{ { @@ -586,7 +586,7 @@ func TestEtcdDeletePod(t *testing.T) { TypeMeta: api.TypeMeta{ID: "foo"}, DesiredState: api.PodState{Host: "machine"}, }), 0) - fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ + fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ Items: []api.BoundPod{ {TypeMeta: api.TypeMeta{ID: "foo"}}, }, @@ -602,7 +602,7 @@ func TestEtcdDeletePod(t *testing.T) { } else if fakeClient.DeletedKeys[0] != key { t.Errorf("Unexpected key: %s, expected %s", fakeClient.DeletedKeys[0], key) } - response, err := fakeClient.Get("/registry/hosts/machine/kubelet", false, false) + response, err := fakeClient.Get("/registry/nodes/machine/boundpods", false, false) if err != nil { t.Fatalf("Unexpected error %v", err) } @@ -622,7 +622,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { TypeMeta: api.TypeMeta{ID: "foo"}, DesiredState: api.PodState{Host: "machine"}, }), 0) - fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ + fakeClient.Set("/registry/nodes/machine/boundpods", runtime.EncodeOrDie(latest.Codec, &api.BoundPods{ Items: []api.BoundPod{ {TypeMeta: api.TypeMeta{ID: "foo"}}, {TypeMeta: api.TypeMeta{ID: "bar"}}, @@ -640,7 +640,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { if fakeClient.DeletedKeys[0] != key { t.Errorf("Unexpected key: %s, expected %s", fakeClient.DeletedKeys[0], key) } - response, err := fakeClient.Get("/registry/hosts/machine/kubelet", false, false) + response, err := fakeClient.Get("/registry/nodes/machine/boundpods", false, false) if err != nil { t.Fatalf("Unexpected error %v", err) }