@@ -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
412412func newPodLister (kubeClient kube_client.Interface , namespace string ) v1lister.PodLister {
0 commit comments