mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Improve kubelet logging around container being killed due to hash change
This commit is contained in:
parent
4f8b821cfd
commit
eb831919d9
@ -672,7 +672,7 @@ func (kl *Kubelet) killContainer(dockerContainer *docker.APIContainers) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) killContainerByID(ID, name string) error {
|
func (kl *Kubelet) killContainerByID(ID, name string) error {
|
||||||
glog.V(2).Infof("Killing: %s", ID)
|
glog.V(2).Infof("Killing container with id %s and name %s", ID, name)
|
||||||
err := kl.dockerClient.StopContainer(ID, 10)
|
err := kl.dockerClient.StopContainer(ID, 10)
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return err
|
return err
|
||||||
@ -783,13 +783,14 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
uuid := pod.UID
|
uuid := pod.UID
|
||||||
containersToKeep := make(map[dockertools.DockerID]empty)
|
containersToKeep := make(map[dockertools.DockerID]empty)
|
||||||
killedContainers := make(map[dockertools.DockerID]empty)
|
killedContainers := make(map[dockertools.DockerID]empty)
|
||||||
|
glog.V(4).Infof("Syncing Pod, podFullName: %s, uuid: %s", podFullName, uuid)
|
||||||
|
|
||||||
// Make sure we have a network container
|
// Make sure we have a network container
|
||||||
var netID dockertools.DockerID
|
var netID dockertools.DockerID
|
||||||
if netDockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, networkContainerName); found {
|
if netDockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, networkContainerName); found {
|
||||||
netID = dockertools.DockerID(netDockerContainer.ID)
|
netID = dockertools.DockerID(netDockerContainer.ID)
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("Network container doesn't exist for pod %q, re-creating the pod", podFullName)
|
glog.V(2).Infof("Network container doesn't exist for pod %q, killing and re-creating the pod", podFullName)
|
||||||
count, err := kl.killContainersInPod(pod, dockerContainers)
|
count, err := kl.killContainersInPod(pod, dockerContainers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -845,9 +846,9 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
containersToKeep[containerID] = empty{}
|
containersToKeep[containerID] = empty{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glog.V(1).Infof("pod %s container %s is unhealthy.", podFullName, container.Name, healthy)
|
glog.V(1).Infof("pod %s container %s is unhealthy. Container will be killed and re-created.", podFullName, container.Name, healthy)
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("container hash changed %d vs %d.", hash, expectedHash)
|
glog.V(1).Infof("pod %s container %s hash changed (%d vs %d). Container will be killed and re-created.", podFullName, container.Name, hash, expectedHash)
|
||||||
}
|
}
|
||||||
if err := kl.killContainer(dockerContainer); err != nil {
|
if err := kl.killContainer(dockerContainer); err != nil {
|
||||||
glog.V(1).Infof("Failed to kill container %s: %v", dockerContainer.ID, err)
|
glog.V(1).Infof("Failed to kill container %s: %v", dockerContainer.ID, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user