diff --git a/node/pod.go b/node/pod.go index be010ba91..441ef3134 100644 --- a/node/pod.go +++ b/node/pod.go @@ -150,6 +150,9 @@ func podShouldEnqueue(oldPod, newPod *corev1.Pod) bool { if !oldPod.DeletionTimestamp.Equal(newPod.DeletionTimestamp) { return true } + if newPod.DeletionTimestamp != nil && !running(&newPod.Status) { + return true + } return false } diff --git a/node/pod_test.go b/node/pod_test.go index 39adc61b7..a0563f85c 100644 --- a/node/pod_test.go +++ b/node/pod_test.go @@ -207,6 +207,27 @@ func TestPodShouldEnqueueGraceTimeChanged(t *testing.T) { assert.Assert(t, podShouldEnqueue(p1, p2)) } +func TestPodShouldEnqueueAllContainersDead(t *testing.T) { + p1 := &corev1.Pod{ + Spec: newPodSpec(), + } + + p2 := p1.DeepCopy() + deletionTimestamp := v1.NewTime(time.Now().Add(time.Hour)) + p2.DeletionTimestamp = &deletionTimestamp + for i := 0; i < len(p2.Status.ContainerStatuses); i++ { + p2.Status.ContainerStatuses[i].State = corev1.ContainerState{ + Waiting: nil, + Running: nil, + Terminated: &corev1.ContainerStateTerminated{ + ExitCode: 1, + Message: "Exit", + }, + } + } + assert.Assert(t, podShouldEnqueue(p1, p2)) +} + func TestPodCreateNewPod(t *testing.T) { svr := newTestController()