From 38ad742d61fd9e297eb5315c71b06936e7e434ad Mon Sep 17 00:00:00 2001 From: Shashank Ram Date: Thu, 24 Jun 2021 12:20:38 -0700 Subject: [PATCH] envoy/eds: fix cluster name to mesh service parsing Change db538a1f8 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 --- pkg/envoy/eds/response.go | 4 ++-- pkg/envoy/eds/response_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/envoy/eds/response.go b/pkg/envoy/eds/response.go index 5784f5dece..18a44cb08d 100644 --- a/pkg/envoy/eds/response.go +++ b/pkg/envoy/eds/response.go @@ -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: /, Got: %s", cluster) + if len(chunks) != 3 { + return service.MeshService{}, errors.Errorf("Invalid cluster name. Expected: //, Got: %s", cluster) } return service.MeshService{ Namespace: chunks[0], diff --git a/pkg/envoy/eds/response_test.go b/pkg/envoy/eds/response_test.go index 96b207c5f5..d9cee930a2 100644 --- a/pkg/envoy/eds/response_test.go +++ b/pkg/envoy/eds/response_test.go @@ -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) @@ -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", @@ -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, },