From adb4a4fbb27e68ba9b1c348951f642a223fb995e Mon Sep 17 00:00:00 2001 From: James Szalay Date: Wed, 20 Nov 2024 02:27:46 +0000 Subject: [PATCH] Fixes issue #4888. Include record type in dedupe key. --- source/dedupsource.go | 2 +- source/dedupsource_test.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source/dedupsource.go b/source/dedupsource.go index 758da43cbf..0ae79e9887 100644 --- a/source/dedupsource.go +++ b/source/dedupsource.go @@ -45,7 +45,7 @@ func (ms *dedupSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, err } for _, ep := range endpoints { - identifier := ep.DNSName + " / " + ep.SetIdentifier + " / " + ep.Targets.String() + identifier := ep.RecordType + " / " + ep.DNSName + " / " + ep.SetIdentifier + " / " + ep.Targets.String() if _, ok := collected[identifier]; ok { log.Debugf("Removing duplicate endpoint %s", ep) diff --git a/source/dedupsource_test.go b/source/dedupsource_test.go index bbd3a21c71..c371db28a1 100644 --- a/source/dedupsource_test.go +++ b/source/dedupsource_test.go @@ -90,6 +90,27 @@ func testDedupEndpoints(t *testing.T) { {DNSName: "foo.example.org", Targets: endpoint.Targets{"1.2.3.4"}}, }, }, + { + "two endpoints with same dnsname, same type, and same target return one endpoint", + []*endpoint.Endpoint{ + {DNSName: "foo.example.org", RecordType: "A", Targets: endpoint.Targets{"1.2.3.4"}}, + {DNSName: "foo.example.org", RecordType: "A", Targets: endpoint.Targets{"1.2.3.4"}}, + }, + []*endpoint.Endpoint{ + {DNSName: "foo.example.org", RecordType: "A", Targets: endpoint.Targets{"1.2.3.4"}}, + }, + }, + { + "two endpoints with same dnsname, different record type, and same target return two endpoints", + []*endpoint.Endpoint{ + {DNSName: "foo.example.org", RecordType: "A", Targets: endpoint.Targets{"1.2.3.4"}}, + {DNSName: "foo.example.org", RecordType: "AAAA", Targets: endpoint.Targets{"1.2.3.4"}}, + }, + []*endpoint.Endpoint{ + {DNSName: "foo.example.org", RecordType: "A", Targets: endpoint.Targets{"1.2.3.4"}}, + {DNSName: "foo.example.org", RecordType: "AAAA", Targets: endpoint.Targets{"1.2.3.4"}}, + }, + }, } { t.Run(tc.title, func(t *testing.T) { mockSource := new(testutils.MockSource)