From 2a92eb808530f6f2ca64133d7a2b03ace3b142f6 Mon Sep 17 00:00:00 2001 From: Jesse Gonzalez Date: Tue, 15 Nov 2022 00:52:25 -0600 Subject: [PATCH 1/5] fix: Support conversion from/to simple to/from other routing policies for the AWS provider. --- provider/aws/aws.go | 6 ++++-- provider/aws/aws_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index e7f24d3a22..70f3b0562c 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -444,8 +444,10 @@ func (p *AWSProvider) createUpdateChanges(newEndpoints, oldEndpoints []*endpoint old := oldEndpoints[i] if new.RecordType != old.RecordType || // Handle the case where an AWS ALIAS record is changing to/from a CNAME. - (old.RecordType == endpoint.RecordTypeCNAME && useAlias(old, p.preferCNAME) != useAlias(new, p.preferCNAME)) { - // The record type changed, so UPSERT will fail. Instead perform a DELETE followed by a CREATE. + (old.RecordType == endpoint.RecordTypeCNAME && useAlias(old, p.preferCNAME) != useAlias(new, p.preferCNAME)) || + // Handle the case where an AWS record is changing to/from simple to other routing policies + ((old.SetIdentifier == "" && new.SetIdentifier != "") || (old.SetIdentifier != "" && new.SetIdentifier == "")) { + // The record type changed or the routing policy change, so UPSERT will fail. Instead perform a DELETE followed by a CREATE. deletes = append(deletes, old) creates = append(creates, new) } else { diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go index 0a0e5a39aa..0115747d54 100644 --- a/provider/aws/aws_test.go +++ b/provider/aws/aws_test.go @@ -526,6 +526,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpointWithTTL("delete-test-cname-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "qux.elb.amazonaws.com"), endpoint.NewEndpointWithTTL("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8", "8.8.4.4"), endpoint.NewEndpointWithTTL("delete-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4", "4.3.2.1"), + endpoint.NewEndpointWithTTL("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpointWithTTL("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"), }) createRecords := []*endpoint.Endpoint{ @@ -544,6 +546,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("update-test-cname.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, "bar.elb.amazonaws.com"), endpoint.NewEndpoint("update-test-cname-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, "bar.elb.amazonaws.com"), endpoint.NewEndpoint("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "8.8.8.8", "8.8.4.4"), + endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), } updatedRecords := []*endpoint.Endpoint{ endpoint.NewEndpoint("update-test.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), @@ -553,6 +557,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("update-test-cname.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, "baz.elb.amazonaws.com"), endpoint.NewEndpoint("update-test-cname-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, "baz.elb.amazonaws.com"), endpoint.NewEndpoint("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4", "4.3.2.1"), + endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), + endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("simple-to-weighted").WithProviderSpecific(providerSpecificWeight, "10"), } deleteRecords := []*endpoint.Endpoint{ @@ -596,6 +602,9 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpointWithTTL("update-test-cname-alias.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "baz.elb.amazonaws.com"), endpoint.NewEndpointWithTTL("create-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8", "8.8.4.4"), endpoint.NewEndpointWithTTL("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4", "4.3.2.1"), + endpoint.NewEndpointWithTTL("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"), + endpoint.NewEndpointWithTTL("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("simple-to-weighted").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpointWithTTL("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificRegion, "us-east-1"), }) } } From b747cc8835e3f65904e3f5d94af8aed038143b23 Mon Sep 17 00:00:00 2001 From: Jesse Gonzalez <191343+jessegonzalez@users.noreply.github.com> Date: Sun, 4 Dec 2022 09:49:56 -0600 Subject: [PATCH 2/5] test(provider/aws): Updating TestAWSApplyChanges() to include a policy change from weighted to latency based routing. --- provider/aws/aws_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go index 0115747d54..c7c99ee16f 100644 --- a/provider/aws/aws_test.go +++ b/provider/aws/aws_test.go @@ -528,6 +528,7 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpointWithTTL("delete-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4", "4.3.2.1"), endpoint.NewEndpointWithTTL("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpointWithTTL("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"), + endpoint.NewEndpointWithTTL("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificWeight, "10"), }) createRecords := []*endpoint.Endpoint{ @@ -548,6 +549,7 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "8.8.8.8", "8.8.4.4"), endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), + endpoint.NewEndpoint("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificWeight, "10"), } updatedRecords := []*endpoint.Endpoint{ endpoint.NewEndpoint("update-test.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), @@ -559,6 +561,7 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("update-test-multiple.zone-2.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4", "4.3.2.1"), endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("simple-to-weighted").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpoint("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificRegion, "us-east-1"), } deleteRecords := []*endpoint.Endpoint{ From 6580182b79f512618b7f27853a32ae35d35363a9 Mon Sep 17 00:00:00 2001 From: Jesse Gonzalez <191343+jessegonzalez@users.noreply.github.com> Date: Mon, 9 Jan 2023 22:50:12 -0600 Subject: [PATCH 3/5] refactor(provider/aws): Refactor createUpdateChanges() with helper requiresDeleteCreate() to see if change is UPSERT capable. --- provider/aws/aws.go | 40 ++++++++++++++++++++++++++++++++++------ provider/aws/aws_test.go | 8 ++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 70f3b0562c..468a8d4f39 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -435,6 +435,39 @@ func (p *AWSProvider) UpdateRecords(ctx context.Context, updates, current []*end return p.submitChanges(ctx, p.createUpdateChanges(updates, current), zones) } +// Identify if old and new endpoints require DELETE/CREATE instead of UPDATE. +func (p *AWSProvider) requiresDeleteCreate(old *endpoint.Endpoint, new *endpoint.Endpoint) bool { + + // a change of record type + if old.RecordType != new.RecordType { + return true + } + + // an ALIAS record change to/from a CNAME + if old.RecordType == endpoint.RecordTypeCNAME && useAlias(old, p.preferCNAME) != useAlias(new, p.preferCNAME) { + return true + } + + // a change of routing policy + // default to true for geolocation properties if any geolocation property exists in old/new but not the other + for _, propType := range [7]string{providerSpecificWeight, providerSpecificRegion, providerSpecificFailover, + providerSpecificFailover, providerSpecificGeolocationContinentCode, providerSpecificGeolocationCountryCode, + providerSpecificGeolocationSubdivisionCode} { + _, oldPolicy := old.GetProviderSpecificProperty(propType) + _, newPolicy := old.GetProviderSpecificProperty(propType) + if oldPolicy != newPolicy { + return true + } + } + + // a set identifier change + if old.SetIdentifier != new.SetIdentifier { + return true + } + + return false +} + func (p *AWSProvider) createUpdateChanges(newEndpoints, oldEndpoints []*endpoint.Endpoint) []*route53.Change { var deletes []*endpoint.Endpoint var creates []*endpoint.Endpoint @@ -442,12 +475,7 @@ func (p *AWSProvider) createUpdateChanges(newEndpoints, oldEndpoints []*endpoint for i, new := range newEndpoints { old := oldEndpoints[i] - if new.RecordType != old.RecordType || - // Handle the case where an AWS ALIAS record is changing to/from a CNAME. - (old.RecordType == endpoint.RecordTypeCNAME && useAlias(old, p.preferCNAME) != useAlias(new, p.preferCNAME)) || - // Handle the case where an AWS record is changing to/from simple to other routing policies - ((old.SetIdentifier == "" && new.SetIdentifier != "") || (old.SetIdentifier != "" && new.SetIdentifier == "")) { - // The record type changed or the routing policy change, so UPSERT will fail. Instead perform a DELETE followed by a CREATE. + if p.requiresDeleteCreate(old, new) { deletes = append(deletes, old) creates = append(creates, new) } else { diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go index c7c99ee16f..73e2c2a8ae 100644 --- a/provider/aws/aws_test.go +++ b/provider/aws/aws_test.go @@ -529,6 +529,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpointWithTTL("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpointWithTTL("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"), endpoint.NewEndpointWithTTL("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpointWithTTL("set-identifier-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("before").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpointWithTTL("set-identifier-no-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("no-change").WithProviderSpecific(providerSpecificWeight, "10"), }) createRecords := []*endpoint.Endpoint{ @@ -550,6 +552,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("weighted-to-simple").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), endpoint.NewEndpoint("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpoint("set-identifier-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("before").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpoint("set-identifier-no-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("no-change").WithProviderSpecific(providerSpecificWeight, "10"), } updatedRecords := []*endpoint.Endpoint{ endpoint.NewEndpoint("update-test.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), @@ -562,6 +566,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpoint("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4"), endpoint.NewEndpoint("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("simple-to-weighted").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpoint("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificRegion, "us-east-1"), + endpoint.NewEndpoint("set-identifier-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("after").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpoint("set-identifier-no-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, "1.2.3.4").WithSetIdentifier("no-change").WithProviderSpecific(providerSpecificWeight, "20"), } deleteRecords := []*endpoint.Endpoint{ @@ -608,6 +614,8 @@ func TestAWSApplyChanges(t *testing.T) { endpoint.NewEndpointWithTTL("weighted-to-simple.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4"), endpoint.NewEndpointWithTTL("simple-to-weighted.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("simple-to-weighted").WithProviderSpecific(providerSpecificWeight, "10"), endpoint.NewEndpointWithTTL("policy-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("policy-change").WithProviderSpecific(providerSpecificRegion, "us-east-1"), + endpoint.NewEndpointWithTTL("set-identifier-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("after").WithProviderSpecific(providerSpecificWeight, "10"), + endpoint.NewEndpointWithTTL("set-identifier-no-change.zone-1.ext-dns-test-2.teapot.zalan.do", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "1.2.3.4").WithSetIdentifier("no-change").WithProviderSpecific(providerSpecificWeight, "20"), }) } } From 2b28a334c94a5d1da56b0bde4481aadbda934c4b Mon Sep 17 00:00:00 2001 From: Jesse Gonzalez <191343+jessegonzalez@users.noreply.github.com> Date: Tue, 10 Jan 2023 00:12:48 -0600 Subject: [PATCH 4/5] test(aws/provider): Adding test for func requireDelteCreate(). --- provider/aws/aws.go | 13 ++++++------- provider/aws/aws_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 468a8d4f39..b1b5e6aa59 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -437,7 +437,6 @@ func (p *AWSProvider) UpdateRecords(ctx context.Context, updates, current []*end // Identify if old and new endpoints require DELETE/CREATE instead of UPDATE. func (p *AWSProvider) requiresDeleteCreate(old *endpoint.Endpoint, new *endpoint.Endpoint) bool { - // a change of record type if old.RecordType != new.RecordType { return true @@ -448,23 +447,23 @@ func (p *AWSProvider) requiresDeleteCreate(old *endpoint.Endpoint, new *endpoint return true } + // a set identifier change + if old.SetIdentifier != new.SetIdentifier { + return true + } + // a change of routing policy // default to true for geolocation properties if any geolocation property exists in old/new but not the other for _, propType := range [7]string{providerSpecificWeight, providerSpecificRegion, providerSpecificFailover, providerSpecificFailover, providerSpecificGeolocationContinentCode, providerSpecificGeolocationCountryCode, providerSpecificGeolocationSubdivisionCode} { _, oldPolicy := old.GetProviderSpecificProperty(propType) - _, newPolicy := old.GetProviderSpecificProperty(propType) + _, newPolicy := new.GetProviderSpecificProperty(propType) if oldPolicy != newPolicy { return true } } - // a set identifier change - if old.SetIdentifier != new.SetIdentifier { - return true - } - return false } diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go index 73e2c2a8ae..58e18f353e 100644 --- a/provider/aws/aws_test.go +++ b/provider/aws/aws_test.go @@ -1412,3 +1412,31 @@ func addZoneTags(tagMap map[string][]*route53.Tag, zoneID string, tags map[strin func validateRecords(t *testing.T, records []*route53.ResourceRecordSet, expected []*route53.ResourceRecordSet) { assert.ElementsMatch(t, expected, records) } + +func TestRequiresDeleteCreate(t *testing.T) { + provider, _ := newAWSProvider(t, endpoint.NewDomainFilter([]string{"foo.bar."}), provider.NewZoneIDFilter([]string{}), provider.NewZoneTypeFilter(""), defaultEvaluateTargetHealth, false, []*endpoint.Endpoint{}) + + oldRecordType := endpoint.NewEndpointWithTTL("recordType", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8") + newRecordType := endpoint.NewEndpointWithTTL("recordType", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "bar") + + assert.False(t, provider.requiresDeleteCreate(oldRecordType, oldRecordType), "actual and expected endpoints don't match. %+v:%+v", oldRecordType, oldRecordType) + assert.True(t, provider.requiresDeleteCreate(oldRecordType, newRecordType), "actual and expected endpoints don't match. %+v:%+v", oldRecordType, newRecordType) + + oldCNAMEAlias := endpoint.NewEndpointWithTTL("CNAMEAlias", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "bar") + newCNAMEAlias := endpoint.NewEndpointWithTTL("CNAMEAlias", endpoint.RecordTypeCNAME, endpoint.TTL(recordTTL), "bar.us-east-1.elb.amazonaws.com") + + assert.False(t, provider.requiresDeleteCreate(oldCNAMEAlias, oldCNAMEAlias), "actual and expected endpoints don't match. %+v:%+v", oldCNAMEAlias, oldCNAMEAlias.DNSName) + assert.True(t, provider.requiresDeleteCreate(oldCNAMEAlias, newCNAMEAlias), "actual and expected endpoints don't match. %+v:%+v", oldCNAMEAlias, newCNAMEAlias) + + oldPolicy := endpoint.NewEndpointWithTTL("policy", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8").WithSetIdentifier("nochange").WithProviderSpecific(providerSpecificRegion, "us-east-1") + newPolicy := endpoint.NewEndpointWithTTL("policy", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8").WithSetIdentifier("nochange").WithProviderSpecific(providerSpecificWeight, "10") + + assert.False(t, provider.requiresDeleteCreate(oldPolicy, oldPolicy), "actual and expected endpoints don't match. %+v:%+v", oldPolicy, oldPolicy) + assert.True(t, provider.requiresDeleteCreate(oldPolicy, newPolicy), "actual and expected endpoints don't match. %+v:%+v", oldPolicy, newPolicy) + + oldSetIdentifier := endpoint.NewEndpointWithTTL("setIdentifier", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8").WithSetIdentifier("old") + newSetIdentifier := endpoint.NewEndpointWithTTL("setIdentifier", endpoint.RecordTypeA, endpoint.TTL(recordTTL), "8.8.8.8").WithSetIdentifier("new") + + assert.False(t, provider.requiresDeleteCreate(oldSetIdentifier, oldSetIdentifier), "actual and expected endpoints don't match. %+v:%+v", oldSetIdentifier, oldSetIdentifier) + assert.True(t, provider.requiresDeleteCreate(oldSetIdentifier, newSetIdentifier), "actual and expected endpoints don't match. %+v:%+v", oldSetIdentifier, newSetIdentifier) +} From 2296119619292145feab17ce57b804f66dfe5558 Mon Sep 17 00:00:00 2001 From: Jesse Gonzalez <191343+jessegonzalez@users.noreply.github.com> Date: Tue, 10 Jan 2023 00:26:20 -0600 Subject: [PATCH 5/5] chore(provider/ovh): Running go fmt on provider/ovh to fix the build. --- provider/ovh/ovh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/ovh/ovh.go b/provider/ovh/ovh.go index 0a86c65acb..8cdb424ae3 100644 --- a/provider/ovh/ovh.go +++ b/provider/ovh/ovh.go @@ -22,9 +22,9 @@ import ( "fmt" "strings" - "golang.org/x/sync/errgroup" "github.com/ovh/go-ovh/ovh" log "github.com/sirupsen/logrus" + "golang.org/x/sync/errgroup" "sigs.k8s.io/external-dns/endpoint" "sigs.k8s.io/external-dns/plan"