From 2580eb9e68fcb7c33f78b04f6a0072142d493ffb Mon Sep 17 00:00:00 2001 From: Nikola Grcevski <6207777+grcevski@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:14:14 -0500 Subject: [PATCH] Backport 1444 to 1.9 (#1445) --- pkg/internal/kube/store.go | 7 ++++--- pkg/kubecache/meta/informers.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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,