Skip to content

Commit 9614674

Browse files
committed
s
Signed-off-by: Omer Aplatony <[email protected]>
1 parent ac977ed commit 9614674

File tree

1 file changed

+11
-11
lines changed
  • vertical-pod-autoscaler/pkg/updater/logic

1 file changed

+11
-11
lines changed

vertical-pod-autoscaler/pkg/updater/logic/updater.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ func (u *updater) RunOnce(ctx context.Context) {
167167

168168
inPlaceFeatureEnable := features.Enabled(features.InPlaceOrRecreate)
169169

170-
var podsList []*apiv1.Pod
171-
seenPods := sets.New[string]()
170+
seenPods := sets.New[*apiv1.Pod]()
172171

173172
for _, vpa := range vpaList {
174173
if slices.Contains(u.ignoredNamespaces, vpa.Namespace) {
@@ -197,10 +196,7 @@ func (u *updater) RunOnce(ctx context.Context) {
197196

198197
// handle the case of overlapping VPA selectors
199198
for _, pod := range podsWithSelector {
200-
if !seenPods.Has(pod.Name) {
201-
seenPods.Insert(pod.Name)
202-
podsList = append(podsList, pod)
203-
}
199+
seenPods.Insert(pod)
204200
}
205201

206202
vpas = append(vpas, &vpa_api_util.VpaWithSelector{
@@ -218,7 +214,7 @@ func (u *updater) RunOnce(ctx context.Context) {
218214
}
219215

220216
timer.ObserveStep("ListPods")
221-
allLivePods := filterDeletedPods(podsList)
217+
allLivePods := filterDeletedPodsFromSet(seenPods)
222218

223219
controlledPods := make(map[*vpa_types.VerticalPodAutoscaler][]*apiv1.Pod)
224220
for _, pod := range allLivePods {
@@ -403,10 +399,14 @@ func filterNonEvictablePods(pods []*apiv1.Pod, evictionRestriction restriction.P
403399
return filterPods(pods, evictionRestriction.CanEvict)
404400
}
405401

406-
func filterDeletedPods(pods []*apiv1.Pod) []*apiv1.Pod {
407-
return filterPods(pods, func(pod *apiv1.Pod) bool {
408-
return pod.DeletionTimestamp == nil
409-
})
402+
func filterDeletedPodsFromSet(pods sets.Set[*apiv1.Pod]) []*apiv1.Pod {
403+
result := make([]*apiv1.Pod, 0)
404+
for p := range pods {
405+
if p.DeletionTimestamp == nil {
406+
result = append(result, p)
407+
}
408+
}
409+
return result
410410
}
411411

412412
func newPodLister(kubeClient kube_client.Interface, namespace string) v1lister.PodLister {

0 commit comments

Comments
 (0)