From 323858b3ca48ff2e63045f074eadc9e6afa0c6ff Mon Sep 17 00:00:00 2001 From: DanStough Date: Wed, 14 Feb 2024 11:53:26 -0500 Subject: [PATCH] feat(v2dns): support 'cluster' label --- agent/dns/parser.go | 2 +- agent/dns/router_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/dns/parser.go b/agent/dns/parser.go index dd23e91591..1a0f0a601d 100644 --- a/agent/dns/parser.go +++ b/agent/dns/parser.go @@ -33,7 +33,7 @@ func parseLabels(labels []string) (*parsedLabels, bool) { result.Namespace = labels[i] case "ap": result.Partition = labels[i] - case "dc": // TODO (v2-dns): This should also include "cluster" for the new notation. + case "dc", "cluster": result.Datacenter = labels[i] case "sg": result.SamenessGroup = labels[i] diff --git a/agent/dns/router_test.go b/agent/dns/router_test.go index 34acf5b307..94ea7893dd 100644 --- a/agent/dns/router_test.go +++ b/agent/dns/router_test.go @@ -2983,7 +2983,7 @@ func Test_HandleRequest(t *testing.T) { }, Question: []dns.Question{ { - Name: "foo.query.consul.", + Name: "foo.query.dc1.cluster.consul.", Qtype: dns.TypeA, Qclass: dns.ClassINET, }, @@ -3024,6 +3024,7 @@ func Test_HandleRequest(t *testing.T) { Run(func(args mock.Arguments) { req := args.Get(1).(*discovery.QueryPayload) require.Equal(t, "foo", req.Name) + require.Equal(t, "dc1", req.Tenancy.Datacenter) }) }, validateAndNormalizeExpected: true, @@ -3036,7 +3037,7 @@ func Test_HandleRequest(t *testing.T) { Compress: true, Question: []dns.Question{ { - Name: "foo.query.consul.", + Name: "foo.query.dc1.cluster.consul.", Qtype: dns.TypeA, Qclass: dns.ClassINET, }, @@ -3044,7 +3045,7 @@ func Test_HandleRequest(t *testing.T) { Answer: []dns.RR{ &dns.A{ Hdr: dns.RR_Header{ - Name: "foo.query.consul.", + Name: "foo.query.dc1.cluster.consul.", Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 1,