Skip to content

Commit

Permalink
Fix a regression introduced lately: When any given PodInfraContainer …
Browse files Browse the repository at this point in the history
…on a node

is killed, kubelet kills all remaining containers no matter which pod that
container belongs to.

Fixed #5373
  • Loading branch information
dchen1107 committed Mar 13, 2015
1 parent efcde72 commit 732d4cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/kubelet/dockertools/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ func (c DockerContainers) RemoveContainerWithID(containerID DockerID) {
// FindContainersByPod returns the containers that belong to the pod.
func (c DockerContainers) FindContainersByPod(podUID types.UID, podFullName string) DockerContainers {
containers := make(DockerContainers)

for _, dockerContainer := range c {
if len(dockerContainer.Names) == 0 {
continue
Expand Down
32 changes: 27 additions & 5 deletions pkg/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,33 +675,55 @@ func TestSyncPodsDeletesWithNoPodInfraContainer(t *testing.T) {
fakeDocker.ContainerList = []docker.APIContainers{
{
// 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",
},
{
// 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{
{
ObjectMeta: api.ObjectMeta{
UID: "12345678",
Name: "foo",
Name: "foo1",
Namespace: "new",
},
Spec: api.PodSpec{
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())
if err != nil {
t.Errorf("unexpected error: %v", err)
}
waitGroup.Wait()

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
// order here.
Expand Down

0 comments on commit 732d4cb

Please sign in to comment.