in clusterloader2/pkg/measurement/common/service_creation_latency.go [151:204]
func (s *serviceCreationLatencyMeasurement) start() error {
if s.isRunning {
klog.V(2).Infof("%s: service creation latency measurement already running", s)
return nil
}
klog.V(2).Infof("%s: starting service creation latency measurement...", s)
s.isRunning = true
s.stopCh = make(chan struct{})
svcInformer := informer.NewInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
s.selector.ApplySelectors(&options)
return s.client.CoreV1().Services(s.selector.Namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
s.selector.ApplySelectors(&options)
return s.client.CoreV1().Services(s.selector.Namespace).Watch(context.TODO(), options)
},
},
func(oldObj, newObj interface{}) {
f := func() {
s.handleObject(oldObj, newObj)
}
s.queue.Add(&f)
},
)
if err := informer.StartAndSync(svcInformer, s.stopCh, informerSyncTimeout); err != nil {
return err
}
if s.checkIngress {
ingressInformer := informer.NewInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
s.selector.ApplySelectors(&options)
return s.client.NetworkingV1().Ingresses(s.selector.Namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
s.selector.ApplySelectors(&options)
return s.client.NetworkingV1().Ingresses(s.selector.Namespace).Watch(context.TODO(), options)
},
},
func(oldObj, newObj interface{}) {
f := func() {
s.handleIngressObject(oldObj, newObj)
}
s.queue.Add(&f)
},
)
return informer.StartAndSync(ingressInformer, s.stopCh, informerSyncTimeout)
}
return nil
}