mirror of https://github.com/k3s-io/k3s
Merge pull request #4410 from brendandburns/fixer
Don't delete the pod infrastructure container on health check failures.pull/6/head
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)
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
|
@ -1093,11 +1094,13 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||
}
|
||||
killedContainers[containerID] = empty{}
|
||||
|
||||
// Also kill associated pod infra container
|
||||
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
||||
if err := kl.killContainer(podInfraContainer); err != nil {
|
||||
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
|
||||
continue
|
||||
if podChanged {
|
||||
// Also kill associated pod infra container if the pod changed.
|
||||
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
||||
if err := kl.killContainer(podInfraContainer); err != nil {
|
||||
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -983,17 +983,15 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
|||
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
|
||||
// order here.
|
||||
expectedToStop := map[string]bool{
|
||||
"1234": true,
|
||||
"9876": true,
|
||||
}
|
||||
if len(fakeDocker.Stopped) != 2 ||
|
||||
(!expectedToStop[fakeDocker.Stopped[0]] &&
|
||||
expectedToStop[fakeDocker.Stopped[0]]) {
|
||||
if len(fakeDocker.Stopped) != len(expectedToStop) ||
|
||||
!expectedToStop[fakeDocker.Stopped[0]] {
|
||||
t.Errorf("Wrong containers were stopped: %v", fakeDocker.Stopped)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue