diff --git a/pkg/internal/kube/store.go b/pkg/internal/kube/store.go index 86238e6b8..ae5d2ba45 100644 --- a/pkg/internal/kube/store.go +++ b/pkg/internal/kube/store.go @@ -310,16 +310,17 @@ func (s *Store) ServiceNameNamespaceForIP(ip string) (string, string) { s.access.RUnlock() return serviceInfo.Name, serviceInfo.Namespace } + s.access.RUnlock() + + s.access.Lock() + defer s.access.Unlock() name, namespace := "", "" if om, ok := s.objectMetaByIP[ip]; ok { name, namespace = s.serviceNameNamespaceForMetadata(om) } - s.access.RUnlock() - s.access.Lock() s.otelServiceInfoByIP[ip] = OTelServiceNamePair{Name: name, Namespace: namespace} - s.access.Unlock() return name, namespace } diff --git a/pkg/kubecache/meta/informers.go b/pkg/kubecache/meta/informers.go index d8fc72c16..5038335dd 100644 --- a/pkg/kubecache/meta/informers.go +++ b/pkg/kubecache/meta/informers.go @@ -52,7 +52,7 @@ func (inf *Informers) Subscribe(observer Observer) { for _, service := range inf.services.GetStore().List() { // ignore headless services from being added if headlessService(service.(*indexableEntity).EncodedMeta) { - return + continue } if err := observer.On(&informer.Event{ Type: informer.EventType_CREATED,