|
|
|
@ -92,7 +92,7 @@ func (s *ResourceGenerator) endpointsFromSnapshotConnectProxy(cfgSnap *proxycfg.
|
|
|
|
|
// upstream in clusters.go so that the sets of endpoints generated matches
|
|
|
|
|
// the sets of clusters.
|
|
|
|
|
for _, uid := range cfgSnap.ConnectProxy.PeeredUpstreamIDs() { |
|
|
|
|
_, skip := getUpstream(uid) |
|
|
|
|
upstream, skip := getUpstream(uid) |
|
|
|
|
if skip { |
|
|
|
|
// Discovery chain is not associated with a known explicit or implicit upstream so it is skipped.
|
|
|
|
|
continue |
|
|
|
@ -107,7 +107,11 @@ func (s *ResourceGenerator) endpointsFromSnapshotConnectProxy(cfgSnap *proxycfg.
|
|
|
|
|
|
|
|
|
|
clusterName := generatePeeredClusterName(uid, tbs) |
|
|
|
|
|
|
|
|
|
loadAssignment, err := s.makeUpstreamLoadAssignmentForPeerService(cfgSnap, clusterName, uid) |
|
|
|
|
mgwMode := structs.MeshGatewayModeDefault |
|
|
|
|
if upstream != nil { |
|
|
|
|
mgwMode = upstream.MeshGateway.Mode |
|
|
|
|
} |
|
|
|
|
loadAssignment, err := s.makeUpstreamLoadAssignmentForPeerService(cfgSnap, clusterName, uid, mgwMode) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -538,7 +542,12 @@ func makePipeEndpoint(path string) *envoy_endpoint_v3.LbEndpoint {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *ResourceGenerator) makeUpstreamLoadAssignmentForPeerService(cfgSnap *proxycfg.ConfigSnapshot, clusterName string, uid proxycfg.UpstreamID) (*envoy_endpoint_v3.ClusterLoadAssignment, error) { |
|
|
|
|
func (s *ResourceGenerator) makeUpstreamLoadAssignmentForPeerService( |
|
|
|
|
cfgSnap *proxycfg.ConfigSnapshot, |
|
|
|
|
clusterName string, |
|
|
|
|
uid proxycfg.UpstreamID, |
|
|
|
|
upstreamGatewayMode structs.MeshGatewayMode, |
|
|
|
|
) (*envoy_endpoint_v3.ClusterLoadAssignment, error) { |
|
|
|
|
var la *envoy_endpoint_v3.ClusterLoadAssignment |
|
|
|
|
|
|
|
|
|
upstreamsSnapshot, err := cfgSnap.ToConfigSnapshotUpstreams() |
|
|
|
@ -546,11 +555,9 @@ func (s *ResourceGenerator) makeUpstreamLoadAssignmentForPeerService(cfgSnap *pr
|
|
|
|
|
return la, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
upstream := cfgSnap.ConnectProxy.UpstreamConfig[uid] |
|
|
|
|
|
|
|
|
|
// If an upstream is configured with local mesh gw mode, we make a load assignment
|
|
|
|
|
// from the gateway endpoints instead of those of the upstreams.
|
|
|
|
|
if upstream != nil && upstream.MeshGateway.Mode == structs.MeshGatewayModeLocal { |
|
|
|
|
if upstreamGatewayMode == structs.MeshGatewayModeLocal { |
|
|
|
|
localGw, ok := cfgSnap.ConnectProxy.WatchedLocalGWEndpoints.Get(cfgSnap.Locality.String()) |
|
|
|
|
if !ok { |
|
|
|
|
// local GW is not ready; return early
|
|
|
|
@ -643,6 +650,11 @@ func (s *ResourceGenerator) endpointsFromDiscoveryChain(
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mgwMode := structs.MeshGatewayModeDefault |
|
|
|
|
if upstream := cfgSnap.ConnectProxy.UpstreamConfig[uid]; upstream != nil { |
|
|
|
|
mgwMode = upstream.MeshGateway.Mode |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Find all resolver nodes.
|
|
|
|
|
for _, node := range chain.Nodes { |
|
|
|
|
if node.Type != structs.DiscoveryGraphNodeTypeResolver { |
|
|
|
@ -682,7 +694,7 @@ func (s *ResourceGenerator) endpointsFromDiscoveryChain(
|
|
|
|
|
s.Logger.Debug("generating endpoints for", "cluster", targetOpt.clusterName) |
|
|
|
|
targetUID := proxycfg.NewUpstreamIDFromTargetID(targetOpt.targetID) |
|
|
|
|
if targetUID.Peer != "" { |
|
|
|
|
loadAssignment, err := s.makeUpstreamLoadAssignmentForPeerService(cfgSnap, targetOpt.clusterName, targetUID) |
|
|
|
|
loadAssignment, err := s.makeUpstreamLoadAssignmentForPeerService(cfgSnap, targetOpt.clusterName, targetUID, mgwMode) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|