Fix kubelet log message when starting a container
This code can be called not only when a container is dead and restarted, but when is started for the first time too. For example, any pod with initContainer and containers will exhibit this behaviour. The reason is that in that case, the "if createPodSandbox" path will return the initContainers only and on the next call to this function this code is executed to start the containers for the fist time. In that case, it is wrong to log that the container is dead and will be restarted, as it was never started. In fact, the restart count will not be increased. This commit just changes this to say that the container is not in the desired state and should be started. In the end, the kubelet is a state machine and that is all we really care about. No tests are added, as the behaviour was correct and tests don't check logs messages. Signed-off-by: Rodrigo Campos <rodrigo@kinvolk.io>
This commit is contained in:
parent
c73fef52f3
commit
e6c67c32e1
@ -572,7 +572,7 @@ func (m *kubeGenericRuntimeManager) computePodActions(pod *v1.Pod, podStatus *ku
|
||||
// need to restart it.
|
||||
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
||||
if kubecontainer.ShouldContainerBeRestarted(&container, pod, podStatus) {
|
||||
message := fmt.Sprintf("Container %+v is dead, but RestartPolicy says that we should restart it.", container)
|
||||
message := fmt.Sprintf("Container %q of pod %q is not in the desired state and shall be started", container.Name, format.Pod(pod))
|
||||
klog.V(3).Infof(message)
|
||||
changes.ContainersToStart = append(changes.ContainersToStart, idx)
|
||||
if containerStatus != nil && containerStatus.State == kubecontainer.ContainerStateUnknown {
|
||||
|
Loading…
Reference in New Issue
Block a user