mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
kubelet: fix container restart counts
This commit ensures that the container restart count increments monotonically when there is no kubelet restarts.
This commit is contained in:
parent
4c88aeeda2
commit
1e26cdfb67
@ -2353,6 +2353,18 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
|
||||
podFullName := kubecontainer.GetPodFullName(pod)
|
||||
glog.V(3).Infof("Generating status for %q", podFullName)
|
||||
|
||||
if existingStatus, ok := kl.statusManager.GetPodStatus(pod.UID); ok {
|
||||
// This is a hacky fix to ensure container restart counts increment
|
||||
// monotonically. Normally, we should not modify given pod. In this
|
||||
// case, we check if there are cached status for this pod, and update
|
||||
// the pod so that we update restart count appropriately.
|
||||
// TODO(yujuhong): We will not need to count dead containers every time
|
||||
// once we add the runtime pod cache.
|
||||
// Note that kubelet restarts may still cause temporarily setback of
|
||||
// restart counts.
|
||||
pod.Status = existingStatus
|
||||
}
|
||||
|
||||
// TODO: Consider include the container information.
|
||||
if kl.pastActiveDeadline(pod) {
|
||||
reason := "DeadlineExceeded"
|
||||
|
Loading…
Reference in New Issue
Block a user