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

Commit

Permalink
envoy/eds: respond with endpoints for all services (#4088)
Browse files Browse the repository at this point in the history
When generating the EDS response for all upstream
endpoints that the downstream proxy is allowed to
access, create an EDS response for a service without
endpoints as well. This is similar to 78455da which
allowed the XDS state machine to converge when there
are CDS clusters that use EDS for endpoint discovery.

Signed-off-by: Shashank Ram <[email protected]>
  • Loading branch information
shashankram authored Sep 9, 2021
1 parent c1df37d commit 9667f91
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions pkg/envoy/eds/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/openservicemesh/osm/pkg/endpoint"
"github.com/openservicemesh/osm/pkg/envoy"
"github.com/openservicemesh/osm/pkg/envoy/registry"
"github.com/openservicemesh/osm/pkg/errcode"
"github.com/openservicemesh/osm/pkg/identity"
"github.com/openservicemesh/osm/pkg/service"
)
Expand Down Expand Up @@ -66,14 +65,10 @@ func generateEDSConfig(meshCatalog catalog.MeshCataloger, proxy *envoy.Proxy) ([
return nil, err
}

allowedEndpoints, err := getUpstreamEndpointsForProxyIdentity(meshCatalog, proxyIdentity)
if err != nil {
log.Error().Err(err).Msgf("Error looking up endpoints for proxy %s", proxy.String())
return nil, err
}

var edsResources []types.Resource
for svc, endpoints := range allowedEndpoints {
upstreamSvcEndpoints := getUpstreamEndpointsForProxyIdentity(meshCatalog, proxyIdentity)

for svc, endpoints := range upstreamSvcEndpoints {
loadAssignment := newClusterLoadAssignment(svc, endpoints)
edsResources = append(edsResources, loadAssignment)
}
Expand Down Expand Up @@ -109,18 +104,13 @@ func clusterToMeshSvc(cluster string) (service.MeshService, error) {

// getUpstreamEndpointsForProxyIdentity returns only those service endpoints that belong to the allowed upstream service accounts for the proxy
// Note: ServiceIdentity must be in the format "name.namespace" [https://github.com/openservicemesh/osm/issues/3188]
func getUpstreamEndpointsForProxyIdentity(meshCatalog catalog.MeshCataloger, proxyIdentity identity.ServiceIdentity) (map[service.MeshService][]endpoint.Endpoint, error) {
func getUpstreamEndpointsForProxyIdentity(meshCatalog catalog.MeshCataloger, proxyIdentity identity.ServiceIdentity) map[service.MeshService][]endpoint.Endpoint {
allowedServicesEndpoints := make(map[service.MeshService][]endpoint.Endpoint)

for _, dstSvc := range meshCatalog.ListOutboundServicesForIdentity(proxyIdentity) {
endpoints := meshCatalog.ListAllowedUpstreamEndpointsForService(proxyIdentity, dstSvc)
if len(endpoints) == 0 {
log.Error().Str(errcode.Kind, errcode.GetErrCodeWithMetric(errcode.ErrEndpointsNotFound)).
Msgf("Endpoints not found for upstream MeshService %s for proxy identity %s, skipping cluster in EDS response", dstSvc, proxyIdentity)
continue
}
allowedServicesEndpoints[dstSvc] = endpoints
allowedServicesEndpoints[dstSvc] = meshCatalog.ListAllowedUpstreamEndpointsForService(proxyIdentity, dstSvc)
}

log.Trace().Msgf("Allowed outbound service endpoints for proxy with identity %s: %v", proxyIdentity, allowedServicesEndpoints)
return allowedServicesEndpoints, nil
return allowedServicesEndpoints
}

0 comments on commit 9667f91

Please sign in to comment.