Merge pull request #5466 from dchen1107/docker

Fix a regression introduced lately: When any given PodInfraContainer on ...
This commit is contained in:
Victor Marmol 2015-03-13 16:04:01 -07:00
commit b00e82ed93
2 changed files with 27 additions and 6 deletions

View File

@ -423,7 +423,6 @@ func (c DockerContainers) RemoveContainerWithID(containerID DockerID) {
// FindContainersByPod returns the containers that belong to the pod. // FindContainersByPod returns the containers that belong to the pod.
func (c DockerContainers) FindContainersByPod(podUID types.UID, podFullName string) DockerContainers { func (c DockerContainers) FindContainersByPod(podUID types.UID, podFullName string) DockerContainers {
containers := make(DockerContainers) containers := make(DockerContainers)
for _, dockerContainer := range c { for _, dockerContainer := range c {
if len(dockerContainer.Names) == 0 { if len(dockerContainer.Names) == 0 {
continue continue

View File

@ -712,25 +712,47 @@ func TestSyncPodsDeletesWithNoPodInfraContainer(t *testing.T) {
fakeDocker.ContainerList = []docker.APIContainers{ fakeDocker.ContainerList = []docker.APIContainers{
{ {
// format is // k8s_<container-id>_<pod-fullname>_<pod-uid> // format is // k8s_<container-id>_<pod-fullname>_<pod-uid>
Names: []string{"/k8s_bar_foo_new_12345678_0"}, Names: []string{"/k8s_bar1_foo1_new_12345678_0"},
ID: "1234", ID: "1234",
}, },
{
// format is // k8s_<container-id>_<pod-fullname>_<pod-uid>
Names: []string{"/k8s_bar2_foo2_new_87654321_0"},
ID: "5678",
},
{
// format is // k8s_<container-id>_<pod-fullname>_<pod-uid>
Names: []string{"/k8s_POD_foo2_new_87654321_0"},
ID: "8765",
},
} }
kubelet.pods = []api.BoundPod{ kubelet.pods = []api.BoundPod{
{ {
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
UID: "12345678", UID: "12345678",
Name: "foo", Name: "foo1",
Namespace: "new", Namespace: "new",
}, },
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
{Name: "bar"}, {Name: "bar1"},
},
},
},
{
ObjectMeta: api.ObjectMeta{
UID: "87654321",
Name: "foo2",
Namespace: "new",
},
Spec: api.PodSpec{
Containers: []api.Container{
{Name: "bar2"},
}, },
}, },
}, },
} }
waitGroup.Add(1) waitGroup.Add(2)
err := kubelet.SyncPods(kubelet.pods, emptyPodUIDs, time.Now()) err := kubelet.SyncPods(kubelet.pods, emptyPodUIDs, time.Now())
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -738,7 +760,7 @@ func TestSyncPodsDeletesWithNoPodInfraContainer(t *testing.T) {
waitGroup.Wait() waitGroup.Wait()
verifyCalls(t, fakeDocker, []string{ verifyCalls(t, fakeDocker, []string{
"list", "list", "stop", "create", "start", "inspect_container", "create", "start"}) "list", "list", "list", "list", "inspect_container", "inspect_container", "stop", "create", "start", "inspect_container", "create", "start"})
// A map iteration is used to delete containers, so must not depend on // A map iteration is used to delete containers, so must not depend on
// order here. // order here.