@@ -27,10 +27,10 @@ import (
27
27
28
28
v1 "k8s.io/api/core/v1"
29
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
- "k8s.io/apimachinery/pkg/fields"
31
30
"k8s.io/apimachinery/pkg/runtime"
32
31
"k8s.io/apimachinery/pkg/util/wait"
33
32
"k8s.io/client-go/informers"
33
+ coreinformers "k8s.io/client-go/informers/core/v1"
34
34
clientset "k8s.io/client-go/kubernetes"
35
35
"k8s.io/client-go/tools/cache"
36
36
"k8s.io/klog/v2"
@@ -649,9 +649,9 @@ func NewInformerFactory(cs clientset.Interface, resyncPeriod time.Duration) info
649
649
650
650
// newPodInformer creates a shared index informer that returns only non-terminal pods.
651
651
func newPodInformer (cs clientset.Interface , resyncPeriod time.Duration ) cache.SharedIndexInformer {
652
- selector := fields . ParseSelectorOrDie (
653
- "status.phase!=" + string ( v1 . PodSucceeded ) +
654
- ",status.phase!=" + string ( v1 . PodFailed ))
655
- lw := cache . NewListWatchFromClient ( cs . CoreV1 (). RESTClient (), string ( v1 . ResourcePods ), metav1 . NamespaceAll , selector )
656
- return cache . NewSharedIndexInformer ( lw , & v1. Pod {} , resyncPeriod , nil )
652
+ selector := fmt . Sprintf ( "status.phase!=%v,status.phase!=%v" , v1 . PodSucceeded , v1 . PodFailed )
653
+ tweakListOptions := func ( options * metav1. ListOptions ) {
654
+ options . FieldSelector = selector
655
+ }
656
+ return coreinformers . NewFilteredPodInformer ( cs , metav1 . NamespaceAll , resyncPeriod , nil , tweakListOptions )
657
657
}
0 commit comments