mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #4410 from brendandburns/fixer
Don't delete the pod infrastructure container on health check failures.
This commit is contained in:
commit
20dc1c2481
@ -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.
|
||||||
@ -1093,7 +1094,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
}
|
}
|
||||||
killedContainers[containerID] = empty{}
|
killedContainers[containerID] = empty{}
|
||||||
|
|
||||||
// Also kill associated pod infra container
|
if podChanged {
|
||||||
|
// Also kill associated pod infra container if the pod changed.
|
||||||
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
||||||
if err := kl.killContainer(podInfraContainer); err != nil {
|
if err := kl.killContainer(podInfraContainer); err != nil {
|
||||||
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
|
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
|
||||||
@ -1101,6 +1103,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check RestartPolicy for container
|
// Check RestartPolicy for container
|
||||||
recentContainers, err := dockertools.GetRecentDockerContainersWithNameAndUUID(kl.dockerClient, podFullName, uid, container.Name)
|
recentContainers, err := dockertools.GetRecentDockerContainersWithNameAndUUID(kl.dockerClient, podFullName, uid, container.Name)
|
||||||
|
@ -983,17 +983,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user