mirror of https://github.com/k3s-io/k3s
Merge pull request #33467 from ZTE-PaaS/zhangke-patch-053
Automatic merge from submit-queue Variables should be initialized near where it would be used As inner the for-loop, it would continue before hash-value being used, so i thinks the hash value calculation should be moved belowpull/6/head
commit
08dd569424
|
@ -1935,7 +1935,6 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, podStatus *kub
|
|||
|
||||
// check the status of the containers
|
||||
for index, container := range pod.Spec.Containers {
|
||||
expectedHash := kubecontainer.HashContainer(&container)
|
||||
|
||||
containerStatus := podStatus.FindContainerStatusByName(container.Name)
|
||||
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
||||
|
@ -1951,7 +1950,6 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, podStatus *kub
|
|||
}
|
||||
|
||||
containerID := kubecontainer.DockerID(containerStatus.ID.ID)
|
||||
hash := containerStatus.Hash
|
||||
glog.V(3).Infof("pod %q container %q exists as %v", format.Pod(pod), container.Name, containerID)
|
||||
|
||||
if createPodInfraContainer {
|
||||
|
@ -1982,6 +1980,8 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, podStatus *kub
|
|||
|
||||
// At this point, the container is running and pod infra container is good.
|
||||
// We will look for changes and check healthiness for the container.
|
||||
expectedHash := kubecontainer.HashContainer(&container)
|
||||
hash := containerStatus.Hash
|
||||
containerChanged := hash != 0 && hash != expectedHash
|
||||
if containerChanged {
|
||||
message := fmt.Sprintf("pod %q container %q hash changed (%d vs %d), it will be killed and re-created.", format.Pod(pod), container.Name, hash, expectedHash)
|
||||
|
|
Loading…
Reference in New Issue