Don't delete the pod infrastructure container on health check failures.

pull/6/head
Brendan Burns 2015-02-12 21:28:32 -08:00
parent 4d141025da
commit 4dbf98e98f
2 changed files with 12 additions and 11 deletions

View File

@ -1053,7 +1053,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
glog.V(3).Infof("pod %q container %q exists as %v", podFullName, container.Name, containerID) glog.V(3).Infof("pod %q container %q exists as %v", podFullName, container.Name, containerID)
// look for changes in the container. // look for changes in the container.
if hash == 0 || hash == expectedHash { podChanged := hash != 0 && hash != expectedHash
if !podChanged {
// TODO: This should probably be separated out into a separate goroutine. // TODO: This should probably be separated out into a separate goroutine.
// If the container's liveness probe is unsuccessful, set readiness to false. If liveness is succesful, do a readiness check and set // If the container's liveness probe is unsuccessful, set readiness to false. If liveness is succesful, do a readiness check and set
// readiness accordingly. If the initalDelay since container creation on liveness probe has not passed the probe will return Success. // readiness accordingly. If the initalDelay since container creation on liveness probe has not passed the probe will return Success.
@ -1087,11 +1088,13 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
} }
killedContainers[containerID] = empty{} killedContainers[containerID] = empty{}
// Also kill associated pod infra container if podChanged {
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found { // Also kill associated pod infra container if the pod changed.
if err := kl.killContainer(podInfraContainer); err != nil { if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err) if err := kl.killContainer(podInfraContainer); err != nil {
continue glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
continue
}
} }
} }
} }

View File

@ -962,17 +962,15 @@ func TestSyncPodUnhealthy(t *testing.T) {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
verifyCalls(t, fakeDocker, []string{"list", "stop", "stop", "list", "create", "start"}) verifyCalls(t, fakeDocker, []string{"list", "stop", "list", "create", "start"})
// A map interation is used to delete containers, so must not depend on // A map interation is used to delete containers, so must not depend on
// order here. // order here.
expectedToStop := map[string]bool{ expectedToStop := map[string]bool{
"1234": true, "1234": true,
"9876": true,
} }
if len(fakeDocker.Stopped) != 2 || if len(fakeDocker.Stopped) != len(expectedToStop) ||
(!expectedToStop[fakeDocker.Stopped[0]] && !expectedToStop[fakeDocker.Stopped[0]] {
expectedToStop[fakeDocker.Stopped[0]]) {
t.Errorf("Wrong containers were stopped: %v", fakeDocker.Stopped) t.Errorf("Wrong containers were stopped: %v", fakeDocker.Stopped)
} }
} }