From 6e9cb0df71b825eb1be33aa6bd0d321a41da63cd Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 22 Jan 2024 22:00:27 -0700 Subject: [PATCH] Handle unknown and evicted pods Signed-off-by: Darren Shepherd --- pkg/controller/local/pods.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/controller/local/pods.go b/pkg/controller/local/pods.go index 3215adc00..ac990ac9b 100644 --- a/pkg/controller/local/pods.go +++ b/pkg/controller/local/pods.go @@ -18,5 +18,23 @@ func DeletePods(req router.Request, resp router.Response) error { return req.Client.Delete(req.Ctx, pod) } } + + if pod.Status.Phase == corev1.PodRunning && len(pod.Status.ContainerStatuses) > 0 { + allUnknown := true + for _, status := range pod.Status.ContainerStatuses { + if status.State.Terminated == nil || status.State.Terminated.Reason != "Unknown" { + allUnknown = false + break + } + } + if allUnknown { + return req.Client.Delete(req.Ctx, pod) + } + } + + if pod.Status.Reason == "Evicted" { + return req.Client.Delete(req.Ctx, pod) + } + return nil }