From 94b86178897b754c0b0e0cf0d14eac6db5f5359b Mon Sep 17 00:00:00 2001 From: Dave Salisbury Date: Thu, 25 Feb 2021 17:49:16 +1100 Subject: [PATCH 1/2] pdns: create one endpoint per-rrset not one per-record If you had an RRSet that contained multiple records, the provider would end up generating multiple endpoints where really it needs to produce a single endpoint with multiple targets. --- provider/pdns/pdns.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/provider/pdns/pdns.go b/provider/pdns/pdns.go index 8ecd9d8236..a609b281ed 100644 --- a/provider/pdns/pdns.go +++ b/provider/pdns/pdns.go @@ -257,13 +257,16 @@ func NewPDNSProvider(ctx context.Context, config PDNSConfig) (*PDNSProvider, err func (p *PDNSProvider) convertRRSetToEndpoints(rr pgo.RrSet) (endpoints []*endpoint.Endpoint, _ error) { endpoints = []*endpoint.Endpoint{} + var targets = []string{} for _, record := range rr.Records { // If a record is "Disabled", it's not supposed to be "visible" if !record.Disabled { - endpoints = append(endpoints, endpoint.NewEndpointWithTTL(rr.Name, rr.Type_, endpoint.TTL(rr.Ttl), record.Content)) + targets = append(targets, record.Content) } } + + endpoints = append(endpoints, endpoint.NewEndpointWithTTL(rr.Name, rr.Type_, endpoint.TTL(rr.Ttl), targets...)) return endpoints, nil } From f4a1b675a9b9f6cb64b04a47c746b27616c9e07d Mon Sep 17 00:00:00 2001 From: Dave Salisbury Date: Thu, 25 Feb 2021 17:49:20 +1100 Subject: [PATCH 2/2] pdns_test: update multiple/mixed record expected values --- provider/pdns/pdns_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/provider/pdns/pdns_test.go b/provider/pdns/pdns_test.go index cfd0b099b5..4fc2dc61ae 100644 --- a/provider/pdns/pdns_test.go +++ b/provider/pdns/pdns_test.go @@ -125,17 +125,13 @@ var ( endpoint.NewEndpointWithTTL("does.not.exist.com", endpoint.RecordTypeTXT, endpoint.TTL(300), "\"heritage=external-dns,external-dns/owner=tower-pdns\""), } endpointsMultipleRecords = []*endpoint.Endpoint{ - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.8.8"), - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.4.4"), - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "4.4.4.4"), + endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.8.8", "8.8.4.4", "4.4.4.4"), } endpointsMixedRecords = []*endpoint.Endpoint{ endpoint.NewEndpointWithTTL("cname.example.com", endpoint.RecordTypeCNAME, endpoint.TTL(300), "example.by.any.other.name.com"), endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeTXT, endpoint.TTL(300), "'would smell as sweet'"), - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.8.8"), - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.4.4"), - endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "4.4.4.4"), + endpoint.NewEndpointWithTTL("example.com", endpoint.RecordTypeA, endpoint.TTL(300), "8.8.8.8", "8.8.4.4", "4.4.4.4"), } endpointsMultipleZones = []*endpoint.Endpoint{