From 2162ec5dc47a0570e310438054dc6c0419798b97 Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Wed, 20 Mar 2024 12:23:47 -0400 Subject: [PATCH] Backport of Bugfix: Don't recreate servicemap for catalog sync into release/1.2.x (#3789) backport of commit 5208e7b67a8b14b60025f4570b4a41b18437c3d2 Co-authored-by: jukie <10012479+Jukie@users.noreply.github.com> --- control-plane/catalog/to-consul/resource.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/control-plane/catalog/to-consul/resource.go b/control-plane/catalog/to-consul/resource.go index d3bbee3df6..064b175aca 100644 --- a/control-plane/catalog/to-consul/resource.go +++ b/control-plane/catalog/to-consul/resource.go @@ -878,22 +878,9 @@ func (t *serviceEndpointsResource) Upsert(endptKey string, raw interface{}) erro svc.serviceLock.Lock() defer svc.serviceLock.Unlock() - // Extract service name and format key - svcName := endpointSlice.Labels[discoveryv1.LabelServiceName] + // Extract service name and format the service key svcKey := endpointSlice.Namespace + "/" + endpointSlice.Labels[discoveryv1.LabelServiceName] - if svc.serviceMap == nil { - svc.serviceMap = make(map[string]*corev1.Service) - } - var err error - if svc.serviceMap[svcKey] == nil { - svc.serviceMap[svcKey], err = t.Service.Client.CoreV1().Services(endpointSlice.Namespace).Get(t.Ctx, svcName, metav1.GetOptions{}) - if err != nil { - t.Log.Error("issue getting service", "error", err) - return err - } - } - // Check if we care about endpoints for this service if !svc.shouldTrackEndpoints(svcKey) { return nil