Skip to content

Commit

Permalink
[API Gateway] Fix trust domain for external peered services in synthe…
Browse files Browse the repository at this point in the history
…sis code
  • Loading branch information
Andrew Stucki committed Jun 7, 2023
1 parent 8118aae commit 63e8743
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions agent/proxycfg/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,23 @@ type configSnapshotAPIGateway struct {

func (c *configSnapshotAPIGateway) synthesizeChains(datacenter string, listener structs.APIGatewayListener, boundListener structs.BoundAPIGatewayListener) ([]structs.IngressService, structs.Upstreams, []*structs.CompiledDiscoveryChain, error) {
chains := []*structs.CompiledDiscoveryChain{}
trustDomain := ""

// We leverage the test trust domain knowing
// that the domain will get overridden if
// there is a target to something other than an
// external/peered service. If the below
// code doesn't get a trust domain due to all the
// targets being external, the chain will
// have the domain munged anyway during synthesis.
trustDomain := connect.TestTrustDomain

DOMAIN_LOOP:
for _, chain := range c.DiscoveryChain {
for _, target := range chain.Targets {
if !target.External {
trustDomain = connect.TrustDomainForTarget(*target)
if trustDomain != "" {
domain := connect.TrustDomainForTarget(*target)
if domain != "" {
trustDomain = domain
break DOMAIN_LOOP
}
}
Expand Down

0 comments on commit 63e8743

Please sign in to comment.