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 <rongjun0821@gmail.com>

* Update discovery/kubernetes/endpointslice.go

Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
Signed-off-by: Ryan Wu <rongjun0821@gmail.com>

* Update endpointslice.go

Signed-off-by: Ryan Wu <rongjun0821@gmail.com>

---------

Signed-off-by: Ryan Wu <rongjun0821@gmail.com>
Co-authored-by: Ayoub Mrini <ayoubmrini424@gmail.com>
This commit is contained in:
Ryan Wu 2025-04-16 22:43:30 +08:00 committed by GitHub
parent ba8609fbd0
commit b4d3c06acb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
}
}