Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
envoy/eds: fix cluster name to mesh service parsing
Browse files Browse the repository at this point in the history
Change db538a1 introduced a regression where the cluster
name is not correctly parsed to retrieve the mesh service.

This causes EDS to error and endpoints to not be
programmed.

Signed-off-by: Shashank Ram <[email protected]>
  • Loading branch information
shashankram committed Jun 24, 2021
1 parent 660aef4 commit 38ad742
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/envoy/eds/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func generateEDSConfig(meshCatalog catalog.MeshCataloger, proxy *envoy.Proxy) ([

func clusterToMeshSvc(cluster string) (service.MeshService, error) {
chunks := strings.Split(cluster, namespacedNameDelimiter)
if len(chunks) != 2 {
return service.MeshService{}, errors.Errorf("Invalid cluster name. Expected: <namespace>/<name>, Got: %s", cluster)
if len(chunks) != 3 {
return service.MeshService{}, errors.Errorf("Invalid cluster name. Expected: <namespace>/<name>/<cluster>, Got: %s", cluster)
}
return service.MeshService{
Namespace: chunks[0],
Expand Down
6 changes: 3 additions & 3 deletions pkg/envoy/eds/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestEndpointConfiguration(t *testing.T) {
assert.NotNil(proxy)

request := &xds_discovery.DiscoveryRequest{
ResourceNames: []string{"default/bookstore-v1"},
ResourceNames: []string{"default/bookstore-v1/local"},
}
resources, err := NewResponse(meshCatalog, proxy, request, mockConfigurator, nil, nil)
assert.Nil(err)
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestClusterToMeshSvc(t *testing.T) {
}{
{
name: "valid cluster name",
cluster: "foo/bar",
cluster: "foo/bar/local",
expectedMeshSvc: service.MeshService{
Namespace: "foo",
Name: "bar",
Expand All @@ -113,7 +113,7 @@ func TestClusterToMeshSvc(t *testing.T) {
},
{
name: "invalid cluster name",
cluster: "foo/bar/baz",
cluster: "foo/barbaz",
expectedMeshSvc: service.MeshService{},
expectError: true,
},
Expand Down

0 comments on commit 38ad742

Please sign in to comment.