Skip to content

Commit

Permalink
Delete a pod from the eviction requests cache when new pod update dos…
Browse files Browse the repository at this point in the history
…t not have the annotation

Just in case the annotation got removed but the pod stayed in the cache
  • Loading branch information
ingvagabund committed Nov 19, 2024
1 parent bb084d6 commit 4425072
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/descheduler/evictions/evictions.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ func NewPodEvictor(
}
// Ignore pod's that are not subject to an eviction in background
if _, exists := newPod.Annotations[EvictionRequestAnnotationKey]; !exists {
if has, err := erCache.hasPod(newPod); err == nil && has {
klog.V(3).InfoS("Pod with eviction in background lost annotation. Removing pod from the cache.", "pod", klog.KObj(newPod))
}
if err := erCache.deletePod(newPod); err != nil {
// If the deletion fails the cache may block eviction
klog.ErrorS(err, "Unable to delete updated pod from cache", "pod", newPod)
}
return
}
// Remove completed/suceeeded or failed pods from the cache
Expand Down Expand Up @@ -374,8 +381,6 @@ func NewPodEvictor(
go erCache.run(ctx)

podEvictor.erCache = erCache
} else {
podEvictor.erCache = newEvictionRequestsCache(assumedEvictionRequestTimeoutSeconds)
}

return podEvictor, nil
Expand Down

0 comments on commit 4425072

Please sign in to comment.