mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
kubelet: fix erratic restart count caused per-container restart backoff
This commit is contained in:
parent
cfe2bf10f2
commit
9cdb004851
@ -476,6 +476,14 @@ func (dm *DockerManager) GetPodStatus(pod *api.Pod) (*api.PodStatus, error) {
|
|||||||
if containerStatus, found := statuses[container.Name]; found {
|
if containerStatus, found := statuses[container.Name]; found {
|
||||||
reason, ok := dm.reasonCache.Get(uid, container.Name)
|
reason, ok := dm.reasonCache.Get(uid, container.Name)
|
||||||
if ok && reason == kubecontainer.ErrCrashLoopBackOff.Error() {
|
if ok && reason == kubecontainer.ErrCrashLoopBackOff.Error() {
|
||||||
|
// We need to increment the restart count if we are going to
|
||||||
|
// move the current state to last terminated state.
|
||||||
|
if containerStatus.State.Terminated != nil {
|
||||||
|
lastObservedTime, ok := lastObservedTime[container.Name]
|
||||||
|
if !ok || containerStatus.State.Terminated.FinishedAt.After(lastObservedTime.Time) {
|
||||||
|
containerStatus.RestartCount += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
containerStatus.LastTerminationState = containerStatus.State
|
containerStatus.LastTerminationState = containerStatus.State
|
||||||
containerStatus.State.Waiting = &api.ContainerStateWaiting{Reason: reason}
|
containerStatus.State.Waiting = &api.ContainerStateWaiting{Reason: reason}
|
||||||
containerStatus.State.Running = nil
|
containerStatus.State.Running = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user