From 24ee8a0488e1ed32eb7a285d2d55628f957a59ce Mon Sep 17 00:00:00 2001 From: freddygv Date: Fri, 19 Mar 2021 19:59:00 -0600 Subject: [PATCH] Prevent requests without UpstreamIDs from being flagged as legacy. New clients in transparent proxy mode can send requests for service config resolution without any upstream args because they do not have explicitly defined upstreams. Old clients on the other hand will never send requests without the Upstreams args unless they don't have upstreams, in which case we do not send back upstream config. --- agent/consul/config_endpoint.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/consul/config_endpoint.go b/agent/consul/config_endpoint.go index 3367ff799d..a3f39f7b11 100644 --- a/agent/consul/config_endpoint.go +++ b/agent/consul/config_endpoint.go @@ -410,13 +410,14 @@ func (c *ConfigEntry) ResolveServiceConfig(args *structs.ServiceConfigRequest, r upstreamIDs := args.UpstreamIDs legacyUpstreams := false - // Before Consul namespaces were released, the Upstreams provided to the endpoint did not contain the namespace. - // Because of this we attach the enterprise meta of the request, which will just be the default namespace. - if len(upstreamIDs) == 0 { + // The request is considered legacy if the deprecated args.Upstream was used + if len(upstreamIDs) == 0 && len(args.Upstreams) > 0 { legacyUpstreams = true upstreamIDs = make([]structs.ServiceID, 0) for _, upstream := range args.Upstreams { + // Before Consul namespaces were released, the Upstreams provided to the endpoint did not contain the namespace. + // Because of this we attach the enterprise meta of the request, which will just be the default namespace. sid := structs.NewServiceID(upstream, &args.EnterpriseMeta) upstreamIDs = append(upstreamIDs, sid) }