From 8f4a08a7e66b0ab449dcb5ab8640a75d82d06539 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 1 May 2023 18:33:29 -0400 Subject: [PATCH] ROUTE53: Fix "No such DNS type error" on legacy or ignored records (#2294) Co-authored-by: Tom Limoncelli --- integrationTest/integration_test.go | 13 +++++++++++++ models/target.go | 2 ++ pkg/diff2/handsoff.go | 4 ++-- pkg/diff2/handsoff_test.go | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index b9147d936..de6eadc26 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -1543,6 +1543,19 @@ func makeTests(t *testing.T) []*TestGroup { ), ), + // Bug https://github.com/StackExchange/dnscontrol/issues/2285 + testgroup("R53_alias pre-existing", + requires(providers.CanUseRoute53Alias), + tc("Create some records", + r53alias("dev-system", "CNAME", "dev-system18.**current-domain**"), + cname("dev-system18", "ec2-54-91-33-155.compute-1.amazonaws.com."), + ), + tc("Add a new record - ignoring foo", + a("bar", "1.2.3.4"), + ignoreName("dev-system*"), + ), + ), + // CLOUDFLAREAPI features testgroup("CF_REDIRECT", diff --git a/models/target.go b/models/target.go index 256fa6369..6d3c38620 100644 --- a/models/target.go +++ b/models/target.go @@ -86,6 +86,8 @@ func (rc *RecordConfig) zoneFileQuoted() string { // GetTargetRFC1035Quoted returns the target as it would be in an // RFC1035-style zonefile. +// Do not use this function if RecordConfig might be a pseudo-rtype +// such as R53_ALIAS. Use GetTargetCombined() instead. func (rc *RecordConfig) GetTargetRFC1035Quoted() string { return rc.zoneFileQuoted() } diff --git a/pkg/diff2/handsoff.go b/pkg/diff2/handsoff.go index 130b800dc..cbe59898c 100644 --- a/pkg/diff2/handsoff.go +++ b/pkg/diff2/handsoff.go @@ -132,7 +132,7 @@ func handsoff( if len(conflicts) != 0 { msgs = append(msgs, fmt.Sprintf("INFO: %d records that are both IGNORE*()'d and not ignored:", len(conflicts))) for _, r := range conflicts { - msgs = append(msgs, fmt.Sprintf(" %s %s %s", r.GetLabelFQDN(), r.Type, r.GetTargetRFC1035Quoted())) + msgs = append(msgs, fmt.Sprintf(" %s %s %s", r.GetLabelFQDN(), r.Type, r.GetTargetCombined())) } if unmanagedSafely { return nil, nil, fmt.Errorf(strings.Join(msgs, "\n") + @@ -157,7 +157,7 @@ func reportSkips(recs models.Records, full bool) []string { } for _, r := range recs[:last] { - msgs = append(msgs, fmt.Sprintf(" %s. %s %s", r.GetLabelFQDN(), r.Type, r.GetTargetRFC1035Quoted())) + msgs = append(msgs, fmt.Sprintf(" %s. %s %s", r.GetLabelFQDN(), r.Type, r.GetTargetCombined())) } if shorten { msgs = append(msgs, fmt.Sprintf(" ...and %d more... (use --full to show all)", len(recs)-maxReport)) diff --git a/pkg/diff2/handsoff_test.go b/pkg/diff2/handsoff_test.go index 0ec01eab6..6b336ca13 100644 --- a/pkg/diff2/handsoff_test.go +++ b/pkg/diff2/handsoff_test.go @@ -36,7 +36,7 @@ func showRecs(recs models.Records) string { for _, rec := range recs { result += (rec.GetLabel() + " " + rec.Type + - " " + rec.GetTargetRFC1035Quoted() + + " " + rec.GetTargetCombined() + "\n") } return result