Skip to content

Commit

Permalink
List EndpointSlices only from the Service namespace to build endpoint…
Browse files Browse the repository at this point in the history
…s conf
  • Loading branch information
ffilippopoulos committed Jul 14, 2023
1 parent 0a4b06f commit 9b60149
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kube/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9b60149

Please sign in to comment.