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

Commit

Permalink
ref: method comments and logging cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Leigh <[email protected]>
  • Loading branch information
allenlsy committed Jul 8, 2021
1 parent 78d4e97 commit 67af702
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/catalog/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (mc *MeshCatalog) GetResolvableServiceEndpoints(svc service.MeshService) ([
return endpoints, nil
}

// ListEndpointsForServiceIdentity returns only those endpoints for a allowed outbound service accounts
// for the given downstream identity
// ListEndpointsForServiceIdentity returns a list of endpoints that belongs to an upstream service accounts
// from the given downstream identity's perspective
// Note: ServiceIdentity must be in the format "name.namespace" [https://github.com/openservicemesh/osm/issues/3188]
func (mc *MeshCatalog) ListEndpointsForServiceIdentity(downstreamIdentity identity.ServiceIdentity, upstreamSvc service.MeshService) ([]endpoint.Endpoint, error) {
outboundEndpoints, err := mc.listEndpointsForService(upstreamSvc)
Expand All @@ -52,7 +52,6 @@ func (mc *MeshCatalog) ListEndpointsForServiceIdentity(downstreamIdentity identi
ipStr := ep.IP.String()
outboundEndpointsSet[ipStr] = append(outboundEndpointsSet[ipStr], ep)
}
log.Info().Msgf("outbound endpoints: %v", outboundEndpointsSet)

destSvcIdentities, err := mc.ListAllowedOutboundServiceIdentities(downstreamIdentity)
if err != nil {
Expand All @@ -64,14 +63,11 @@ func (mc *MeshCatalog) ListEndpointsForServiceIdentity(downstreamIdentity identi
// i.e. only those interseting endpoints are taken into cosideration
var allowedEndpoints []endpoint.Endpoint
for _, destSvcIdentity := range destSvcIdentities {
log.Info().Msgf("ups svc endpoints: %v, %v", destSvcIdentity, mc.listEndpointsForServiceIdentity(destSvcIdentity))

for _, ep := range mc.listEndpointsForServiceIdentity(destSvcIdentity) {
epIPStr := ep.IP.String()
// check if endpoint IP is allowed
if _, ok := outboundEndpointsSet[epIPStr]; ok {
// add all allowed endpoints on the pod to result list
// TODO(allenlsy): only allow endpoint with matching port
allowedEndpoints = append(allowedEndpoints, outboundEndpointsSet[epIPStr]...)
}
}
Expand Down

0 comments on commit 67af702

Please sign in to comment.