Skip to content

Commit

Permalink
chore: replace deprecated NewIndexerInformer
Browse files Browse the repository at this point in the history
Signed-off-by: Omer Aplatony <[email protected]>
  • Loading branch information
omerap12 committed Jan 23, 2025
1 parent 041e9d4 commit 9e9f365
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package input
import (
"context"
"fmt"
"os"
"slices"
"time"

Expand Down Expand Up @@ -170,8 +171,12 @@ func newPodClients(kubeClient kube_client.Interface, resourceEventHandler cache.
Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
}

_, controller := cache.NewInformerWithOptions(informerOptions)
indexer := cache.NewIndexer(cache.DeletionHandlingMetaNamespaceKeyFunc, informerOptions.Indexers)
store, controller := cache.NewInformerWithOptions(informerOptions)
indexer, ok := store.(cache.Indexer)
if !ok {
klog.ErrorS(nil, "Expected Indexer, but got a Store that does not implement Indexer")
os.Exit(255)
}
podLister := v1lister.NewPodLister(indexer)
go controller.Run(stopCh)
if !cache.WaitForCacheSync(stopCh, controller.HasSynced) {
Expand Down
8 changes: 6 additions & 2 deletions vertical-pod-autoscaler/pkg/utils/vpa/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ func NewVpasLister(vpaClient *vpa_clientset.Clientset, stopChannel <-chan struct
Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
}

_, controller := cache.NewInformerWithOptions(informerOptions)
indexer := cache.NewIndexer(cache.DeletionHandlingMetaNamespaceKeyFunc, informerOptions.Indexers)
store, controller := cache.NewInformerWithOptions(informerOptions)
indexer, ok := store.(cache.Indexer)
if !ok {
klog.ErrorS(nil, "Expected Indexer, but got a Store that does not implement Indexer")
os.Exit(255)
}
vpaLister := vpa_lister.NewVerticalPodAutoscalerLister(indexer)
go controller.Run(stopChannel)
if !cache.WaitForCacheSync(stopChannel, controller.HasSynced) {
Expand Down

0 comments on commit 9e9f365

Please sign in to comment.