Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List EndpointSlices only from the Service namespace to build endpoint… #93

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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