Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: When pod exceeds we find that, The pod is correctly states with the reason but as you can see above the container state is still reported as What you expected to happen: Container state should be not because pod has exceeded How to reproduce it (as minimally and precisely as possible): Create the pod described above and wait till it exceeds listed . Then get the container status using, Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig node
I would like to address this :) /assign
thanks.

Discussion:
} // optimization: avoid invoking the pod worker if no further changes are possible to the pod definition <del> if podWorkerTerminal { klog.V(4).Infof("Pod %q has completed, ignoring remaining sync work: %s", format.Pod(pod), syncType) </del> <ins> // (i.e. the pod has completed and its containers have been terminated) if podWorkerTerminal && containersTerminal { klog.V(4).InfoS("Pod has completed and its containers have been terminated, ignoring remaining sync work", "pod", klog.KObj(pod), "syncType", syncType) </ins> return }

assert.True(t, calledFunctionCount > 2, "expect more than two PodContainerManager calls") } <ins> func TestDispatchWorkOfCompletedPod(t *testing.T) { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) defer testKubelet.Cleanup() kubelet := testKubelet.kubelet kubelet.podWorkers = &fakePodWorkers{ syncPodFn: func(options syncPodOptions) error { return fmt.Errorf("should ignore completed pod %q", options.pod.Name) }, cache: kubelet.podCache, t:     t, } now := metav1.NewTime(time.Now()) pods := []*v1.Pod{ { ObjectMeta: metav1.ObjectMeta{ UID:         "1", Name:        "completed-pod1", Namespace:   "ns", Annotations: make(map[string]string), }, Status: v1.PodStatus{ Phase: v1.PodFailed, ContainerStatuses: []v1.ContainerStatus{ { State: v1.ContainerState{ Terminated: &v1.ContainerStateTerminated{}, }, }, }, }, }, { ObjectMeta: metav1.ObjectMeta{ UID:         "2", Name:        "completed-pod2", Namespace:   "ns", Annotations: make(map[string]string), }, Status: v1.PodStatus{ Phase: v1.PodSucceeded, ContainerStatuses: []v1.ContainerStatus{ { State: v1.ContainerState{ Terminated: &v1.ContainerStateTerminated{}, }, }, }, }, }, { ObjectMeta: metav1.ObjectMeta{ UID:               "3", Name:              "completed-pod3", Namespace:         "ns", Annotations:       make(map[string]string), DeletionTimestamp: &now, }, Status: v1.PodStatus{ ContainerStatuses: []v1.ContainerStatus{ { State: v1.ContainerState{ Terminated: &v1.ContainerStateTerminated{}, }, }, }, }, }, } for _, pod := range pods { kubelet.dispatchWork(pod, kubetypes.SyncPodSync, nil, time.Now()) } } func TestDispatchWorkOfActivePod(t *testing.T) { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) defer testKubelet.Cleanup() kubelet := testKubelet.kubelet var got bool kubelet.podWorkers = &fakePodWorkers{ syncPodFn: func(options syncPodOptions) error { got = true return nil }, cache: kubelet.podCache, t:     t, } pods := []*v1.Pod{ { ObjectMeta: metav1.ObjectMeta{ UID:         "1", Name:        "active-pod1", Namespace:   "ns", Annotations: make(map[string]string), }, Status: v1.PodStatus{ Phase: v1.PodRunning, }, }, { ObjectMeta: metav1.ObjectMeta{ UID:         "2", Name:        "active-pod2", Namespace:   "ns", Annotations: make(map[string]string), }, Status: v1.PodStatus{ Phase: v1.PodFailed, ContainerStatuses: []v1.ContainerStatus{ { State: v1.ContainerState{ Running: &v1.ContainerStateRunning{}, }, }, }, }, }, } for _, pod := range pods { kubelet.dispatchWork(pod, kubetypes.SyncPodSync, nil, time.Now()) if !got { t.Errorf("Should not skip active pod %q", pod.Name) } got = false } } </ins> func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) { ready := false