diff --git a/.changelog/19860.txt b/.changelog/19860.txt new file mode 100644 index 000000000..e4edb69d8 --- /dev/null +++ b/.changelog/19860.txt @@ -0,0 +1,3 @@ +```release-note:bug +connect: Solves an issue where two upstream services with the same name in different namespaces were not getting routed to correctly by API Gateways. +``` diff --git a/agent/consul/discoverychain/gateway.go b/agent/consul/discoverychain/gateway.go index d4447db73..eac04ce8c 100644 --- a/agent/consul/discoverychain/gateway.go +++ b/agent/consul/discoverychain/gateway.go @@ -254,7 +254,7 @@ func targetForResolverNode(nodeName string, chains []*structs.CompiledDiscoveryC splitterName := splitterPrefix + strings.TrimPrefix(nodeName, resolverPrefix) for _, c := range chains { - targetChainPrefix := resolverPrefix + c.ServiceName + "." + targetChainPrefix := resolverPrefix + c.ID() if strings.HasPrefix(nodeName, targetChainPrefix) && len(c.Nodes) == 1 { // we have a virtual resolver that just maps to another resolver, return // the given node name diff --git a/agent/consul/discoverychain/gateway_test.go b/agent/consul/discoverychain/gateway_test.go index 6a1ea344a..c5eb575c5 100644 --- a/agent/consul/discoverychain/gateway_test.go +++ b/agent/consul/discoverychain/gateway_test.go @@ -618,6 +618,7 @@ func TestGatewayChainSynthesizer_Synthesize(t *testing.T) { chain: &structs.CompiledDiscoveryChain{ ServiceName: "foo", Namespace: "default", + Partition: "default", Datacenter: "dc1", StartNode: "resolver:foo-2.default.default.dc2", Nodes: map[string]*structs.DiscoveryGraphNode{