From b4d3c06acb805f9b9e786eb268b7cea84b34d1b0 Mon Sep 17 00:00:00 2001 From: Ryan Wu Date: Wed, 16 Apr 2025 22:43:30 +0800 Subject: [PATCH] discovery: make endpointSlice discovery more efficient (#16433) * discovery: a change to a service with the same name but from another namespace won't enqueue the endpointSlice Signed-off-by: Ryan Wu * Update discovery/kubernetes/endpointslice.go Co-authored-by: Ayoub Mrini Signed-off-by: Ryan Wu * Update endpointslice.go Signed-off-by: Ryan Wu --------- Signed-off-by: Ryan Wu Co-authored-by: Ayoub Mrini --- discovery/kubernetes/endpointslice.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discovery/kubernetes/endpointslice.go b/discovery/kubernetes/endpointslice.go index 7331605f9b..1002025128 100644 --- a/discovery/kubernetes/endpointslice.go +++ b/discovery/kubernetes/endpointslice.go @@ -110,7 +110,8 @@ func NewEndpointSlice(l *slog.Logger, eps cache.SharedIndexInformer, svc, pod, n e.logger.Error("converting to EndpointSlice object failed", "err", err) continue } - if lv, exists := es.Labels[v1.LabelServiceName]; exists && lv == svc.Name { + // Only consider the underlying EndpointSlices in the same namespace. + if svcName, exists := es.Labels[v1.LabelServiceName]; exists && svcName == svc.Name && es.Namespace == svc.Namespace { e.enqueue(es) } }