Skip to content

Commit

Permalink
Make it so Succeeded pods are not deleted immediately (#3878)
Browse files Browse the repository at this point in the history
Once a pod has succeeded, we will delete it is older than MinimumPodAge

The issue with this is that we start the "timer" when the last container started, so any pod that runs for longer than MinimumPodAge will be deleted immediately on completing

Now we will start the "timer" based on the time it became terminated, so it will stick for a minimum of MinimumPodAge duration after it finishes

Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Co-authored-by: Mustafa Ilyas <MustafaI@users.noreply.github.com>
  • Loading branch information
JamesMurkin and MustafaI authored Aug 14, 2024
1 parent 7a22411 commit a2d3a7f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/executor/service/resource_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,12 @@ func (r *ResourceCleanupService) canPodBeRemoved(pod *v1.Pod) bool {
return false
}

lastContainerStart := util.FindLastContainerStartTime(pod)
if lastContainerStart.Add(r.kubernetesConfiguration.MinimumPodAge).After(time.Now()) {
lastChange, err := util.LastStatusChange(pod)
if err == nil && lastChange.Add(r.kubernetesConfiguration.MinimumPodAge).After(time.Now()) {
return false
}

if pod.Status.Phase == v1.PodFailed {
lastChange, err := util.LastStatusChange(pod)
if err == nil && lastChange.Add(r.kubernetesConfiguration.FailedPodExpiry).After(time.Now()) {
return false
}
Expand Down

0 comments on commit a2d3a7f

Please sign in to comment.