Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Handle unknown and evicted pods
Browse files Browse the repository at this point in the history
Signed-off-by: Darren Shepherd <[email protected]>
  • Loading branch information
ibuildthecloud committed Jan 23, 2024
1 parent 95dfdfb commit 6e9cb0d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/controller/local/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 6e9cb0d

Please sign in to comment.