From 9b60149ae1a1ba516c79edd69e0ea9600809e947 Mon Sep 17 00:00:00 2001 From: Foivos Filippopoulos Date: Fri, 14 Jul 2023 12:05:41 +0100 Subject: [PATCH] List EndpointSlices only from the Service namespace to build endpoints conf --- controller/controller.go | 4 ++-- kube/client.go | 6 +++--- kube/client_mock.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 358828d..91c261c 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -233,7 +233,7 @@ func (c *Controller) endpointsStoreForXdsServiceStore(svcs xds.XdsServiceStore) store := xds.NewXdsEnpointStore() for _, s := range svcs.All() { // Add EndpointSlices from the local cluster - es, err := c.localClient.EndpointSliceList(fmt.Sprintf("%s=%s", kube.KubernetesIOServiceNameLabel, s.Service.Name)) + es, err := c.localClient.EndpointSliceList(fmt.Sprintf("%s=%s", kube.KubernetesIOServiceNameLabel, s.Service.Name), s.Service.Namespace) if err != nil { return nil, err } @@ -251,7 +251,7 @@ func (c *Controller) endpointsStoreForXdsServiceStore(svcs xds.XdsServiceStore) priority = uint32(1) } for _, client := range c.remoteClients { - es, err := client.EndpointSliceList(fmt.Sprintf("%s=%s", kube.KubernetesIOServiceNameLabel, s.Service.Name)) + es, err := client.EndpointSliceList(fmt.Sprintf("%s=%s", kube.KubernetesIOServiceNameLabel, s.Service.Name), s.Service.Namespace) if err != nil { return nil, err } diff --git a/kube/client.go b/kube/client.go index 5471129..2e9b56a 100644 --- a/kube/client.go +++ b/kube/client.go @@ -98,7 +98,7 @@ type Client interface { KubeClient() kubernetes.Interface Service(namespace, name string) (*corev1.Service, error) EndpointSlice(name, namespace string) (*discoveryv1.EndpointSlice, error) - EndpointSliceList(labelSelector string) ([]*discoveryv1.EndpointSlice, error) + EndpointSliceList(labelSelector, namespace string) ([]*discoveryv1.EndpointSlice, error) XdsServiceList() ([]*v1alpha1.XdsService, error) } @@ -213,7 +213,7 @@ func (c *clientWrapper) EndpointSlice(name, namespace string) (*discoveryv1.Endp } // EndpointSliceList returns all the EndpointSlices selected by a label -func (c *clientWrapper) EndpointSliceList(labelSelector string) ([]*discoveryv1.EndpointSlice, error) { +func (c *clientWrapper) EndpointSliceList(labelSelector, namespace string) ([]*discoveryv1.EndpointSlice, error) { // Return an empty slice if watcher is not initialised yet (for remote watchers) if c.factoryKube == nil { return []*discoveryv1.EndpointSlice{}, nil @@ -222,7 +222,7 @@ func (c *clientWrapper) EndpointSliceList(labelSelector string) ([]*discoveryv1. if err != nil { return []*discoveryv1.EndpointSlice{}, err } - return filterKubeNotFound(c.factoryKube.Discovery().V1().EndpointSlices().Lister().EndpointSlices(metav1.NamespaceAll).List(selector)) + return filterKubeNotFound(c.factoryKube.Discovery().V1().EndpointSlices().Lister().EndpointSlices(namespace).List(selector)) } // XdsServiceList lists the watched XdsServices resources diff --git a/kube/client_mock.go b/kube/client_mock.go index 89610f0..ff7f2d3 100644 --- a/kube/client_mock.go +++ b/kube/client_mock.go @@ -141,7 +141,7 @@ func (c *clientMock) EndpointSlice(name, namespace string) (*discoveryv1.Endpoin } // EndpointSliceList returns all the EndpointSlices selected by a label -func (c *clientMock) EndpointSliceList(labelSelector string) ([]*discoveryv1.EndpointSlice, error) { +func (c *clientMock) EndpointSliceList(labelSelector, namespace string) ([]*discoveryv1.EndpointSlice, error) { return c.endpointSlices, nil }