From b8053fed819d53d84388b6d34646fec9eef22ccb Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sun, 3 Mar 2024 04:46:43 -0300 Subject: [PATCH 01/22] Group By Endpoint names per Hosted Zone on AWS --- provider/aws/aws.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 7b9dc77237..8b5d46e134 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -979,6 +979,7 @@ func sortChangesByActionNameType(cs Route53Changes) Route53Changes { // changesByZone separates a multi-zone change into a single change per zone. func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Changes) map[string]Route53Changes { changes := make(map[string]Route53Changes) + visitedHostnames := make(map[string]map[string]bool) for _, z := range zones { changes[aws.StringValue(z.Id)] = Route53Changes{} @@ -993,6 +994,15 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { + // Initialize the map for the current zone if it doesn't exist + if visitedHostnames[aws.StringValue(z.Id)] == nil { + visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) + } + + if visitedHostnames[aws.StringValue(z.Id)][hostname] { + log.Debugf("Skipping duplicate %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id)) + continue + } if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail @@ -1008,6 +1018,7 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) + visitedHostnames[aws.StringValue(z.Id)][hostname] = true log.Debugf("Adding %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id)) } } From e55200ae742bf6906641fb6664b2009a5e8d3a66 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sun, 3 Mar 2024 05:12:05 -0300 Subject: [PATCH 02/22] Group By Endpoint names per Hosted Zone on AWS --- provider/aws/aws.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 8b5d46e134..06b8a71abc 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -979,7 +979,7 @@ func sortChangesByActionNameType(cs Route53Changes) Route53Changes { // changesByZone separates a multi-zone change into a single change per zone. func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Changes) map[string]Route53Changes { changes := make(map[string]Route53Changes) - visitedHostnames := make(map[string]map[string]bool) + visitedHostnames := make(map[string]map[string]map[string]bool) for _, z := range zones { changes[aws.StringValue(z.Id)] = Route53Changes{} @@ -994,15 +994,16 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - // Initialize the map for the current zone if it doesn't exist - if visitedHostnames[aws.StringValue(z.Id)] == nil { - visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) + // Initialize the map for the Current Zone & Record Type if it doesn't exist + if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] == nil { + visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] = make(map[string]bool) } - if visitedHostnames[aws.StringValue(z.Id)][hostname] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id)) + if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] { + log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type) continue } + if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail @@ -1018,8 +1019,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) - visitedHostnames[aws.StringValue(z.Id)][hostname] = true - log.Debugf("Adding %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id)) + visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] = true + log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type) } } From 7c7a1c30ef8c2191092e18a23ebddb10cab8e8f0 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sun, 3 Mar 2024 16:36:32 -0300 Subject: [PATCH 03/22] Group By Endpoint names per Hosted Zone on AWS --- provider/aws/aws.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 06b8a71abc..f581fcdf11 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -995,12 +995,12 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } for _, z := range zones { // Initialize the map for the Current Zone & Record Type if it doesn't exist - if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] == nil { - visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type] = make(map[string]bool) + if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] == nil { + visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] = make(map[string]bool) } - if visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type) + if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] { + log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) continue } @@ -1019,8 +1019,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) - visitedHostnames[aws.StringValue(z.Id)][c.ResourceRecordSet.Type][hostname] = true - log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), c.ResourceRecordSet.Type) + visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] = true + log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) } } From 9307374110b97661f1b473d54766e463bdfacf23 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sun, 3 Mar 2024 17:02:35 -0300 Subject: [PATCH 04/22] Group By Endpoint names per Hosted Zone on AWS --- provider/aws/aws.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index f581fcdf11..3d67444199 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -979,7 +979,7 @@ func sortChangesByActionNameType(cs Route53Changes) Route53Changes { // changesByZone separates a multi-zone change into a single change per zone. func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Changes) map[string]Route53Changes { changes := make(map[string]Route53Changes) - visitedHostnames := make(map[string]map[string]map[string]bool) + visitedHostnames := make(map[string]map[string]bool) for _, z := range zones { changes[aws.StringValue(z.Id)] = Route53Changes{} @@ -994,16 +994,18 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - // Initialize the map for the Current Zone & Record Type if it doesn't exist - if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] == nil { - visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type] = make(map[string]bool) + log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), *c.ResourceRecordSet.Type) + key := fmt.Sprintf("%s_%s", hostname, *c.ResourceRecordSet.Type) + log.Debugf("Key Output: %s", key) + // Initialize the map for the current zone if it doesn't exist + if visitedHostnames[aws.StringValue(z.Id)] == nil { + visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) } - if visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) + if visitedHostnames[aws.StringValue(z.Id)][key] { + log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) continue } - if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail @@ -1019,8 +1021,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) - visitedHostnames[aws.StringValue(z.Id)][*c.ResourceRecordSet.Type][hostname] = true - log.Debugf("Adding %s to zone %s [Id: %s] RecordType: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) + visitedHostnames[aws.StringValue(z.Id)][key] = true + log.Debugf("Adding %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) } } From 846f4b40fab641ae4720f418cdc2756b1acc3b2f Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Tue, 5 Mar 2024 02:27:20 -0300 Subject: [PATCH 05/22] Going back to endpoint.go --- endpoint/endpoint.go | 8 ++ endpoint/endpoint_test.go | 188 ++++++++++++++++++++++++++++++++++++++ provider/aws/aws.go | 20 +++- 3 files changed, 211 insertions(+), 5 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index a45f61ac42..0f8d9d7731 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -293,12 +293,20 @@ func (e *Endpoint) String() string { // only endpoints that match. func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered := []*Endpoint{} + visited := make(map[EndpointKey]bool) // Initialize the visited map for _, ep := range eps { + key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} + if visited[key] { //Do not contain duplicated endpoints + log.Debugf(`Already loaded endpoint %v `, ep) + continue + } if endpointOwner, ok := ep.Labels[OwnerLabelKey]; !ok || endpointOwner != ownerID { log.Debugf(`Skipping endpoint %v because owner id does not match, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } else { filtered = append(filtered, ep) + log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } + visited[key] = true } return filtered diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index 47c23e2f4f..cd9a97ae0a 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -216,3 +216,191 @@ func TestIsOwnedBy(t *testing.T) { }) } } + +func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { + foo1 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo2 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo3 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo4 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + bar := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "bar", + }, + } + + type args struct { + ownerID string + eps []*Endpoint + } + tests := []struct { + name string + args args + want []*Endpoint + }{ + { + name: "filter values", + args: args{ + ownerID: "foo", + eps: []*Endpoint{ + foo1, + foo2, + foo3, + foo4, + bar, + }, + }, + want: []*Endpoint{ + foo1, + foo2, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) { + t.Errorf("FilterEndpointsByOwnerID() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { + foo1 := &Endpoint{ + DNSName: "internal.foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo2 := &Endpoint{ + DNSName: "internal.foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo3 := &Endpoint{ + DNSName: "internal.foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo4 := &Endpoint{ + DNSName: "internal.foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo5 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo6 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo7 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + foo8 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeCNAME, + Labels: Labels{ + OwnerLabelKey: "foo", + }, + } + bar := &Endpoint{ + DNSName: "internal.foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "bar", + }, + } + bar2 := &Endpoint{ + DNSName: "foo.com", + RecordType: RecordTypeA, + Labels: Labels{ + OwnerLabelKey: "bar", + }, + } + + type args struct { + ownerID string + eps []*Endpoint + } + tests := []struct { + name string + args args + want []*Endpoint + }{ + { + name: "filter values", + args: args{ + ownerID: "foo", + eps: []*Endpoint{ + foo1, + foo2, + foo3, + foo4, + foo5, + foo6, + foo7, + foo8, + bar, + bar2, + }, + }, + want: []*Endpoint{ + foo1, + foo2, + foo5, + foo6, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) { + t.Errorf("FilterEndpointsByOwnerID() = %v, want %v", got, tt.want) + } + }) + } +} \ No newline at end of file diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 3d67444199..8e53710486 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -994,8 +994,18 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), *c.ResourceRecordSet.Type) - key := fmt.Sprintf("%s_%s", hostname, *c.ResourceRecordSet.Type) + // IMPORTANT EXPLAIN: I tried to fix this in here but a lot of tests started to fail in cascade. + // Found that nil recordTypes are entering in this function + // So disabling the continue will skip the deletion of duplicated records + // But this is the way we want to go. Also adding more visibility using recordType on Debug + var recordType string + if c.ResourceRecordSet.Type != nil && *c.ResourceRecordSet.Type != "" { + recordType = *c.ResourceRecordSet.Type + } else { + recordType = "EmptyRecordType" + } + log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), recordType) + key := fmt.Sprintf("%s_%s", hostname, recordType) log.Debugf("Key Output: %s", key) // Initialize the map for the current zone if it doesn't exist if visitedHostnames[aws.StringValue(z.Id)] == nil { @@ -1003,8 +1013,8 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } if visitedHostnames[aws.StringValue(z.Id)][key] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) - continue + log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) + //continue } if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint @@ -1022,7 +1032,7 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) visitedHostnames[aws.StringValue(z.Id)][key] = true - log.Debugf("Adding %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), *c.ResourceRecordSet.Type) + log.Debugf("Adding %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) } } From 294b4c673ecc6aaff2bb48709d574cd678561c94 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Tue, 5 Mar 2024 02:35:13 -0300 Subject: [PATCH 06/22] Fix format on aws and endpoint files --- endpoint/endpoint.go | 2 +- provider/aws/aws.go | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 0f8d9d7731..02607316a1 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -298,7 +298,7 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} if visited[key] { //Do not contain duplicated endpoints log.Debugf(`Already loaded endpoint %v `, ep) - continue + continue } if endpointOwner, ok := ep.Labels[OwnerLabelKey]; !ok || endpointOwner != ownerID { log.Debugf(`Skipping endpoint %v because owner id does not match, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 8e53710486..87daacd65d 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -994,28 +994,28 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - // IMPORTANT EXPLAIN: I tried to fix this in here but a lot of tests started to fail in cascade. + // IMPORTANT EXPLAIN: I tried to fix this in here but a lot of tests started to fail in cascade. // Found that nil recordTypes are entering in this function // So disabling the continue will skip the deletion of duplicated records // But this is the way we want to go. Also adding more visibility using recordType on Debug var recordType string if c.ResourceRecordSet.Type != nil && *c.ResourceRecordSet.Type != "" { - recordType = *c.ResourceRecordSet.Type + recordType = *c.ResourceRecordSet.Type } else { - recordType = "EmptyRecordType" + recordType = "EmptyRecordType" } log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), recordType) key := fmt.Sprintf("%s_%s", hostname, recordType) log.Debugf("Key Output: %s", key) // Initialize the map for the current zone if it doesn't exist - if visitedHostnames[aws.StringValue(z.Id)] == nil { - visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) - } + if visitedHostnames[aws.StringValue(z.Id)] == nil { + visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) + } if visitedHostnames[aws.StringValue(z.Id)][key] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) - //continue - } + log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) + //continue + } if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail From 0308cc23e2f5ce84fa077931b3346be63eaa55ad Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Tue, 5 Mar 2024 02:50:28 -0300 Subject: [PATCH 07/22] Fix Lint --- go.mod | 12 ++++++------ go.sum | 12 ++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 956661bf43..d894b125c8 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( go.etcd.io/etcd/api/v3 v3.5.12 go.etcd.io/etcd/client/v3 v3.5.12 go.uber.org/ratelimit v0.3.0 - golang.org/x/net v0.21.0 + golang.org/x/net v0.22.0 golang.org/x/oauth2 v0.17.0 golang.org/x/sync v0.6.0 golang.org/x/time v0.5.0 @@ -196,13 +196,13 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.19.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.19.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect diff --git a/go.sum b/go.sum index 1035417019..84c91a7f15 100644 --- a/go.sum +++ b/go.sum @@ -1277,6 +1277,8 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1325,6 +1327,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1396,6 +1400,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1512,6 +1518,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1525,6 +1533,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1632,6 +1642,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 3395eba20ffc85e9fec1b0a061e9db25955a499a Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Tue, 5 Mar 2024 02:59:02 -0300 Subject: [PATCH 08/22] Add const to avoid Lint --- provider/aws/aws.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 87daacd65d..41c6616a7f 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -59,6 +59,7 @@ const ( providerSpecificMultiValueAnswer = "aws/multi-value-answer" providerSpecificHealthCheckID = "aws/health-check-id" sameZoneAlias = "same-zone" + EmptyRecordType = "EmptyRecordType" ) // see: https://docs.aws.amazon.com/general/latest/gr/elb.html @@ -1002,7 +1003,7 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change if c.ResourceRecordSet.Type != nil && *c.ResourceRecordSet.Type != "" { recordType = *c.ResourceRecordSet.Type } else { - recordType = "EmptyRecordType" + recordType = EmptyRecordType } log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), recordType) key := fmt.Sprintf("%s_%s", hostname, recordType) From cea0496a958f6ffb83112acdc87d84f27a5fff75 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Tue, 5 Mar 2024 11:32:02 -0300 Subject: [PATCH 09/22] Revert "Fix Lint" This reverts commit 0308cc23e2f5ce84fa077931b3346be63eaa55ad. --- go.mod | 12 ++++++------ go.sum | 12 ------------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index d894b125c8..956661bf43 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( go.etcd.io/etcd/api/v3 v3.5.12 go.etcd.io/etcd/client/v3 v3.5.12 go.uber.org/ratelimit v0.3.0 - golang.org/x/net v0.22.0 + golang.org/x/net v0.21.0 golang.org/x/oauth2 v0.17.0 golang.org/x/sync v0.6.0 golang.org/x/time v0.5.0 @@ -196,13 +196,13 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + golang.org/x/crypto v0.19.0 // indirect golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/term v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.19.0 // indirect + golang.org/x/tools v0.17.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect diff --git a/go.sum b/go.sum index 84c91a7f15..1035417019 100644 --- a/go.sum +++ b/go.sum @@ -1277,8 +1277,6 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1327,8 +1325,6 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1400,8 +1396,6 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1518,8 +1512,6 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1533,8 +1525,6 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1642,8 +1632,6 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From a3826d541bc7071d3920715a9f5a89e92abe1cec Mon Sep 17 00:00:00 2001 From: leonardocaylent <146885187+leonardocaylent@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:56:02 -0300 Subject: [PATCH 10/22] Update endpoint.go with Key function --- endpoint/endpoint.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 02607316a1..e9d4132615 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -295,7 +295,8 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered := []*Endpoint{} visited := make(map[EndpointKey]bool) // Initialize the visited map for _, ep := range eps { - key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} + //key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong + key := ep.Key() // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. if visited[key] { //Do not contain duplicated endpoints log.Debugf(`Already loaded endpoint %v `, ep) continue From 30c9e77765df4300be4145858cc81707d1db1db3 Mon Sep 17 00:00:00 2001 From: leonardocaylent <146885187+leonardocaylent@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:00:00 -0300 Subject: [PATCH 11/22] Fix lint --- endpoint/endpoint.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index e9d4132615..3bb50107ec 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -295,8 +295,9 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered := []*Endpoint{} visited := make(map[EndpointKey]bool) // Initialize the visited map for _, ep := range eps { - //key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong - key := ep.Key() // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. + // key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong + key := ep.Key() + // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. if visited[key] { //Do not contain duplicated endpoints log.Debugf(`Already loaded endpoint %v `, ep) continue From 0ca279694a231dc0ac234c8d72e0f32c0a9286fb Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sat, 16 Mar 2024 11:41:26 -0300 Subject: [PATCH 12/22] Fix Lint --- endpoint/endpoint.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 3bb50107ec..68342e1bb9 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -293,11 +293,13 @@ func (e *Endpoint) String() string { // only endpoints that match. func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered := []*Endpoint{} - visited := make(map[EndpointKey]bool) // Initialize the visited map + // Initialize the map for detecting duplicated endpoints + visited := make(map[EndpointKey]bool) + for _, ep := range eps { // key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong key := ep.Key() - // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. + // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. if visited[key] { //Do not contain duplicated endpoints log.Debugf(`Already loaded endpoint %v `, ep) continue @@ -308,7 +310,9 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered = append(filtered, ep) log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } - visited[key] = true + if (key != EndpointKey{}) { + visited[key] = true + } } return filtered From 82046ccb15325b9ea8d1de9b2376e9c17d2edb37 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sat, 16 Mar 2024 15:05:59 -0300 Subject: [PATCH 13/22] Removing comments and clean up --- endpoint/endpoint.go | 9 +++++---- provider/aws/aws.go | 18 ------------------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 68342e1bb9..2b04c1d785 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -297,11 +297,10 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { visited := make(map[EndpointKey]bool) for _, ep := range eps { - // key := EndpointKey{DNSName: ep.DNSName, RecordType: ep.RecordType, SetIdentifier: ep.SetIdentifier} --< this line passes the unit tests but I think it's wrong key := ep.Key() - // This function should be the primary key for endpoints but it's only considering DNSName, RecordType & SetIdentifier. + // Using EndpointKey for getting the primary key using DNSName, RecordType & SetIdentifier. if visited[key] { //Do not contain duplicated endpoints - log.Debugf(`Already loaded endpoint %v `, ep) + log.Debugf(`Skipping duplicated endpoint %v `, ep) continue } if endpointOwner, ok := ep.Labels[OwnerLabelKey]; !ok || endpointOwner != ownerID { @@ -310,7 +309,9 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered = append(filtered, ep) log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } - if (key != EndpointKey{}) { + // Adding validation (skipping empty EndpointKeys) + // Not sure why we have cases when there are empty keys, but we do + if key != (EndpointKey{}) { visited[key] = true } } diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 41c6616a7f..18b67ff720 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -980,7 +980,6 @@ func sortChangesByActionNameType(cs Route53Changes) Route53Changes { // changesByZone separates a multi-zone change into a single change per zone. func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Changes) map[string]Route53Changes { changes := make(map[string]Route53Changes) - visitedHostnames := make(map[string]map[string]bool) for _, z := range zones { changes[aws.StringValue(z.Id)] = Route53Changes{} @@ -995,28 +994,12 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - // IMPORTANT EXPLAIN: I tried to fix this in here but a lot of tests started to fail in cascade. - // Found that nil recordTypes are entering in this function - // So disabling the continue will skip the deletion of duplicated records - // But this is the way we want to go. Also adding more visibility using recordType on Debug var recordType string if c.ResourceRecordSet.Type != nil && *c.ResourceRecordSet.Type != "" { recordType = *c.ResourceRecordSet.Type } else { recordType = EmptyRecordType } - log.Debugf("Creating key for %s to zone %s with type %s", hostname, aws.StringValue(z.Id), recordType) - key := fmt.Sprintf("%s_%s", hostname, recordType) - log.Debugf("Key Output: %s", key) - // Initialize the map for the current zone if it doesn't exist - if visitedHostnames[aws.StringValue(z.Id)] == nil { - visitedHostnames[aws.StringValue(z.Id)] = make(map[string]bool) - } - - if visitedHostnames[aws.StringValue(z.Id)][key] { - log.Debugf("Skipping duplicate %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) - //continue - } if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail @@ -1032,7 +1015,6 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) - visitedHostnames[aws.StringValue(z.Id)][key] = true log.Debugf("Adding %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) } } From 7fe2d3f0696e54f9a0d7e03c5465f2e1e7b8613f Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Fri, 29 Mar 2024 03:39:17 -0300 Subject: [PATCH 14/22] Fix for duplicated endpoints and unit tests --- endpoint/endpoint.go | 8 ++---- endpoint/endpoint_test.go | 59 +++------------------------------------ provider/aws/aws.go | 9 +----- 3 files changed, 7 insertions(+), 69 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 2b04c1d785..9c918cfb76 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -298,7 +298,7 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { for _, ep := range eps { key := ep.Key() - // Using EndpointKey for getting the primary key using DNSName, RecordType & SetIdentifier. + // Using EndpointKey to generate the primary key using DNSName, RecordType & SetIdentifier. if visited[key] { //Do not contain duplicated endpoints log.Debugf(`Skipping duplicated endpoint %v `, ep) continue @@ -307,12 +307,8 @@ func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { log.Debugf(`Skipping endpoint %v because owner id does not match, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } else { filtered = append(filtered, ep) - log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) - } - // Adding validation (skipping empty EndpointKeys) - // Not sure why we have cases when there are empty keys, but we do - if key != (EndpointKey{}) { visited[key] = true + log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } } diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index cd9a97ae0a..9f009a4b4f 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -226,26 +226,12 @@ func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { }, } foo2 := &Endpoint{ - DNSName: "foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } - foo3 := &Endpoint{ DNSName: "foo.com", RecordType: RecordTypeA, Labels: Labels{ OwnerLabelKey: "foo", }, } - foo4 := &Endpoint{ - DNSName: "foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } bar := &Endpoint{ DNSName: "foo.com", RecordType: RecordTypeA, @@ -270,14 +256,11 @@ func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { eps: []*Endpoint{ foo1, foo2, - foo3, - foo4, bar, }, }, want: []*Endpoint{ foo1, - foo2, }, }, } @@ -299,54 +282,26 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { }, } foo2 := &Endpoint{ - DNSName: "internal.foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } - foo3 := &Endpoint{ DNSName: "internal.foo.com", RecordType: RecordTypeA, Labels: Labels{ OwnerLabelKey: "foo", }, } - foo4 := &Endpoint{ - DNSName: "internal.foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } - foo5 := &Endpoint{ + foo3 := &Endpoint{ DNSName: "foo.com", RecordType: RecordTypeA, Labels: Labels{ OwnerLabelKey: "foo", }, } - foo6 := &Endpoint{ - DNSName: "foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } - foo7 := &Endpoint{ + foo4 := &Endpoint{ DNSName: "foo.com", RecordType: RecordTypeA, Labels: Labels{ OwnerLabelKey: "foo", }, } - foo8 := &Endpoint{ - DNSName: "foo.com", - RecordType: RecordTypeCNAME, - Labels: Labels{ - OwnerLabelKey: "foo", - }, - } bar := &Endpoint{ DNSName: "internal.foo.com", RecordType: RecordTypeA, @@ -380,19 +335,13 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { foo2, foo3, foo4, - foo5, - foo6, - foo7, - foo8, bar, bar2, }, }, want: []*Endpoint{ foo1, - foo2, - foo5, - foo6, + foo3, }, }, } @@ -403,4 +352,4 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { } }) } -} \ No newline at end of file +} diff --git a/provider/aws/aws.go b/provider/aws/aws.go index 18b67ff720..7b9dc77237 100644 --- a/provider/aws/aws.go +++ b/provider/aws/aws.go @@ -59,7 +59,6 @@ const ( providerSpecificMultiValueAnswer = "aws/multi-value-answer" providerSpecificHealthCheckID = "aws/health-check-id" sameZoneAlias = "same-zone" - EmptyRecordType = "EmptyRecordType" ) // see: https://docs.aws.amazon.com/general/latest/gr/elb.html @@ -994,12 +993,6 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change continue } for _, z := range zones { - var recordType string - if c.ResourceRecordSet.Type != nil && *c.ResourceRecordSet.Type != "" { - recordType = *c.ResourceRecordSet.Type - } else { - recordType = EmptyRecordType - } if c.ResourceRecordSet.AliasTarget != nil && aws.StringValue(c.ResourceRecordSet.AliasTarget.HostedZoneId) == sameZoneAlias { // alias record is to be created; target needs to be in the same zone as endpoint // if it's not, this will fail @@ -1015,7 +1008,7 @@ func changesByZone(zones map[string]*route53.HostedZone, changeSet Route53Change } } changes[aws.StringValue(z.Id)] = append(changes[aws.StringValue(z.Id)], c) - log.Debugf("Adding %s to zone %s [Id: %s] Type: %s", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id), recordType) + log.Debugf("Adding %s to zone %s [Id: %s]", hostname, aws.StringValue(z.Name), aws.StringValue(z.Id)) } } From 2b3da1b6080ecd32cdde0cb007cc0839208383e3 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Fri, 29 Mar 2024 23:27:25 -0300 Subject: [PATCH 15/22] Fix for duplicated endpoints and unit tests --- controller/controller.go | 2 ++ endpoint/endpoint.go | 30 +++++++++++++++++++----------- endpoint/endpoint_test.go | 20 ++++++++------------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index a3ef2e8b23..4edf72ebf5 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -210,6 +210,7 @@ func (c *Controller) RunOnce(ctx context.Context) error { return err } + records = endpoint.RemoveDuplicates(records) registryEndpointsTotal.Set(float64(len(records))) regARecords, regAAAARecords := countAddressRecords(records) registryARecords.Set(float64(regARecords)) @@ -230,6 +231,7 @@ func (c *Controller) RunOnce(ctx context.Context) error { verifiedARecords.Set(float64(vARecords)) verifiedAAAARecords.Set(float64(vAAAARecords)) endpoints, err = c.Registry.AdjustEndpoints(endpoints) + endpoints = endpoint.RemoveDuplicates(endpoints) if err != nil { return fmt.Errorf("adjusting endpoints: %w", err) } diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 9c918cfb76..3d6d9161cd 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -293,22 +293,11 @@ func (e *Endpoint) String() string { // only endpoints that match. func FilterEndpointsByOwnerID(ownerID string, eps []*Endpoint) []*Endpoint { filtered := []*Endpoint{} - // Initialize the map for detecting duplicated endpoints - visited := make(map[EndpointKey]bool) - for _, ep := range eps { - key := ep.Key() - // Using EndpointKey to generate the primary key using DNSName, RecordType & SetIdentifier. - if visited[key] { //Do not contain duplicated endpoints - log.Debugf(`Skipping duplicated endpoint %v `, ep) - continue - } if endpointOwner, ok := ep.Labels[OwnerLabelKey]; !ok || endpointOwner != ownerID { log.Debugf(`Skipping endpoint %v because owner id does not match, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } else { filtered = append(filtered, ep) - visited[key] = true - log.Debugf(`Added endpoint %v because owner id matches, found: "%s", required: "%s"`, ep, endpointOwner, ownerID) } } @@ -354,3 +343,22 @@ type DNSEndpointList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []DNSEndpoint `json:"items"` } + +// Apply filter based on EndpointKey (using DNSName, RecordType & SetIdentifier) +func RemoveDuplicates(filtered []*Endpoint) []*Endpoint { + visited := make(map[EndpointKey]bool) + result := []*Endpoint{} + + for _, ep := range filtered { + key := ep.Key() + + if !visited[key] { + result = append(result, ep) + visited[key] = true + } else { + log.Debugf(`Skipping duplicated endpoint: %v`, ep) + } + } + + return result +} diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index 9f009a4b4f..57584d9938 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -217,7 +217,7 @@ func TestIsOwnedBy(t *testing.T) { } } -func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { +func TestDuplicatedEndpointsWithSimpleZone(t *testing.T) { foo1 := &Endpoint{ DNSName: "foo.com", RecordType: RecordTypeA, @@ -241,8 +241,7 @@ func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { } type args struct { - ownerID string - eps []*Endpoint + eps []*Endpoint } tests := []struct { name string @@ -252,7 +251,6 @@ func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { { name: "filter values", args: args{ - ownerID: "foo", eps: []*Endpoint{ foo1, foo2, @@ -266,14 +264,14 @@ func TestDuplicatedFilterEndpointsByOwnerID(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) { - t.Errorf("FilterEndpointsByOwnerID() = %v, want %v", got, tt.want) + if got := RemoveDuplicates(tt.args.eps); !reflect.DeepEqual(got, tt.want) { + t.Errorf("RemoveDuplicates() = %v, want %v", got, tt.want) } }) } } -func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { +func TestDuplicatedEndpointsWithOverlappingZones(t *testing.T) { foo1 := &Endpoint{ DNSName: "internal.foo.com", RecordType: RecordTypeA, @@ -318,8 +316,7 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { } type args struct { - ownerID string - eps []*Endpoint + eps []*Endpoint } tests := []struct { name string @@ -329,7 +326,6 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { { name: "filter values", args: args{ - ownerID: "foo", eps: []*Endpoint{ foo1, foo2, @@ -347,8 +343,8 @@ func TestZonesDuplicatedFilterEndpointsByOwnerID(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) { - t.Errorf("FilterEndpointsByOwnerID() = %v, want %v", got, tt.want) + if got := RemoveDuplicates(tt.args.eps); !reflect.DeepEqual(got, tt.want) { + t.Errorf("RemoveDuplicates() = %v, want %v", got, tt.want) } }) } From 6066b700b871399bdf66670ab6d9725c6037b884 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Thu, 4 Apr 2024 01:24:05 -0300 Subject: [PATCH 16/22] Fix for duplicated endpoints --- controller/controller.go | 1 - endpoint/endpoint.go | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 4edf72ebf5..0cdd82cd6a 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -231,7 +231,6 @@ func (c *Controller) RunOnce(ctx context.Context) error { verifiedARecords.Set(float64(vARecords)) verifiedAAAARecords.Set(float64(vAAAARecords)) endpoints, err = c.Registry.AdjustEndpoints(endpoints) - endpoints = endpoint.RemoveDuplicates(endpoints) if err != nil { return fmt.Errorf("adjusting endpoints: %w", err) } diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 3d6d9161cd..b081455200 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -346,15 +346,15 @@ type DNSEndpointList struct { // Apply filter based on EndpointKey (using DNSName, RecordType & SetIdentifier) func RemoveDuplicates(filtered []*Endpoint) []*Endpoint { - visited := make(map[EndpointKey]bool) + visited := make(map[EndpointKey]struct{}) result := []*Endpoint{} for _, ep := range filtered { key := ep.Key() - if !visited[key] { + if _, found := visited[key]; !found { result = append(result, ep) - visited[key] = true + visited[key] = struct{}{} } else { log.Debugf(`Skipping duplicated endpoint: %v`, ep) } From 3ca4d0250f1c031c6dcc84133081fd4036fbdb65 Mon Sep 17 00:00:00 2001 From: leonardocaylent <146885187+leonardocaylent@users.noreply.github.com> Date: Thu, 4 Apr 2024 16:35:21 -0300 Subject: [PATCH 17/22] Update endpoint/endpoint.go Co-authored-by: Eric Bailey --- endpoint/endpoint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index b081455200..6ab558c083 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -344,7 +344,7 @@ type DNSEndpointList struct { Items []DNSEndpoint `json:"items"` } -// Apply filter based on EndpointKey (using DNSName, RecordType & SetIdentifier) +// RemoveDuplicates returns a slice holding the unique endpoints. func RemoveDuplicates(filtered []*Endpoint) []*Endpoint { visited := make(map[EndpointKey]struct{}) result := []*Endpoint{} From deba1ea445bbb1008d12f650782419a1a2b9aa04 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Thu, 4 Apr 2024 21:15:48 -0300 Subject: [PATCH 18/22] Fix suggestions --- endpoint/endpoint.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 6ab558c083..da262d6d6b 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -345,16 +345,17 @@ type DNSEndpointList struct { } // RemoveDuplicates returns a slice holding the unique endpoints. -func RemoveDuplicates(filtered []*Endpoint) []*Endpoint { +func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint { visited := make(map[EndpointKey]struct{}) result := []*Endpoint{} - for _, ep := range filtered { + for _, ep := range endpoints { key := ep.Key() if _, found := visited[key]; !found { result = append(result, ep) - visited[key] = struct{}{} + //visited[key] = struct{}{} + // Currently Debugging 0.14.0 to see the exact root cause } else { log.Debugf(`Skipping duplicated endpoint: %v`, ep) } From 4fb2f2e283a721cc41112604acea1a3998327398 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Fri, 5 Apr 2024 01:29:38 -0300 Subject: [PATCH 19/22] Specific bugfix near the root cause for duplicated deletes on plan.go --- controller/controller.go | 5 ++++- endpoint/endpoint.go | 3 +-- plan/plan.go | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 0cdd82cd6a..f651f103e4 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -210,7 +210,10 @@ func (c *Controller) RunOnce(ctx context.Context) error { return err } - records = endpoint.RemoveDuplicates(records) + //records = endpoint.RemoveDuplicates(records) + //This deduplication could be a different but valid solution + //With this in place the change on plan.go is not needed + //Keeping this here until we decide what's best registryEndpointsTotal.Set(float64(len(records))) regARecords, regAAAARecords := countAddressRecords(records) registryARecords.Set(float64(regARecords)) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index da262d6d6b..08c9c6b238 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -354,8 +354,7 @@ func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint { if _, found := visited[key]; !found { result = append(result, ep) - //visited[key] = struct{}{} - // Currently Debugging 0.14.0 to see the exact root cause + visited[key] = struct{}{} } else { log.Debugf(`Skipping duplicated endpoint: %v`, ep) } diff --git a/plan/plan.go b/plan/plan.go index b4100328d1..0dc4854ac6 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -252,6 +252,10 @@ func (p *Plan) Calculate() *Plan { // filter out updates this external dns does not have ownership claim over if p.OwnerID != "" { changes.Delete = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.Delete) + // Remove duplicated endpoints generated by plan.go on Line 196 + changes.Delete = endpoint.RemoveDuplicates(changes.Delete) + // This was not needed on version 0.13.6, but it seems like + // the old function/code had the ability of removing duplicated endpoints changes.UpdateOld = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateOld) changes.UpdateNew = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateNew) } From d9b743922ad7fbec94cb765bd384043742ff1fa3 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Sat, 6 Apr 2024 03:25:05 -0300 Subject: [PATCH 20/22] Specify and clarify root cause of issue 4241 --- controller/controller.go | 7 +++++-- endpoint/endpoint.go | 2 ++ plan/plan.go | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index f651f103e4..c1979a6c48 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -210,9 +210,12 @@ func (c *Controller) RunOnce(ctx context.Context) error { return err } - //records = endpoint.RemoveDuplicates(records) - //This deduplication could be a different but valid solution + records = endpoint.RemoveDuplicates(records) + //This deduplication seems to be the a good fit + //Duplicated endpoints were living on this variable + //In all versions for the overlapping zones //With this in place the change on plan.go is not needed + //Also it saves some rounds of cpu //Keeping this here until we decide what's best registryEndpointsTotal.Set(float64(len(records))) regARecords, regAAAARecords := countAddressRecords(records) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 08c9c6b238..26828f0202 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -345,6 +345,8 @@ type DNSEndpointList struct { } // RemoveDuplicates returns a slice holding the unique endpoints. +// This function doesn't contemplate the Targets of an Endpoint +// as part of the primary Key func RemoveDuplicates(endpoints []*Endpoint) []*Endpoint { visited := make(map[EndpointKey]struct{}) result := []*Endpoint{} diff --git a/plan/plan.go b/plan/plan.go index 0dc4854ac6..1f913942f1 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -170,6 +170,20 @@ func (p *Plan) Calculate() *Plan { if p.DomainFilter == nil { p.DomainFilter = endpoint.MatchAllDomainFilters(nil) } + // Root cause of the issue: + // Behavior on 0.14.0 on Deletes + // ------------------------------------------------------------------------------------------------------ + // DNSName | Current record | Desired Records (Candidate) | + // ------------------------------------------------------------------------------------------------------ + // dnsname.zone.com |[dnsname.zone.com IN A]dnsname.zone.com IN A (dup ep)| [] | + // ------------------------------------------------------------------------------------------------------ + // + // Behavior on 0.13.6 on Deletes + // ------------------------------------------------------------------------------------------------------ + // DNSName | Current record | Desired Records (Candidate) | + // ------------------------------------------------------------------------------------------------------ + // dnsname.zone.com | [dnsname.zone.com IN CNAME ] | [] | + // ------------------------------------------------------------------------------------------------------ for _, current := range filterRecordsForPlan(p.Current, p.DomainFilter, p.ManagedRecords, p.ExcludeRecords) { t.addCurrent(current) @@ -252,10 +266,11 @@ func (p *Plan) Calculate() *Plan { // filter out updates this external dns does not have ownership claim over if p.OwnerID != "" { changes.Delete = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.Delete) - // Remove duplicated endpoints generated by plan.go on Line 196 - changes.Delete = endpoint.RemoveDuplicates(changes.Delete) + // Remove duplicated endpoints generated by plan.go on Line 210 + // changes.Delete = endpoint.RemoveDuplicates(changes.Delete) // This was not needed on version 0.13.6, but it seems like // the old function/code had the ability of removing duplicated endpoints + // While the filterRecordsForPlan and addCurrent functions were running changes.UpdateOld = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateOld) changes.UpdateNew = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateNew) } From 64d083330364df2578bf8d8c107a56226534cad0 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Mon, 22 Apr 2024 20:45:28 -0300 Subject: [PATCH 21/22] Final fix for error on delete --- controller/controller.go | 7 ------- plan/plan.go | 20 +------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index c1979a6c48..a3ef2e8b23 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -210,13 +210,6 @@ func (c *Controller) RunOnce(ctx context.Context) error { return err } - records = endpoint.RemoveDuplicates(records) - //This deduplication seems to be the a good fit - //Duplicated endpoints were living on this variable - //In all versions for the overlapping zones - //With this in place the change on plan.go is not needed - //Also it saves some rounds of cpu - //Keeping this here until we decide what's best registryEndpointsTotal.Set(float64(len(records))) regARecords, regAAAARecords := countAddressRecords(records) registryARecords.Set(float64(regARecords)) diff --git a/plan/plan.go b/plan/plan.go index 1f913942f1..d0ca7f96a2 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -170,20 +170,6 @@ func (p *Plan) Calculate() *Plan { if p.DomainFilter == nil { p.DomainFilter = endpoint.MatchAllDomainFilters(nil) } - // Root cause of the issue: - // Behavior on 0.14.0 on Deletes - // ------------------------------------------------------------------------------------------------------ - // DNSName | Current record | Desired Records (Candidate) | - // ------------------------------------------------------------------------------------------------------ - // dnsname.zone.com |[dnsname.zone.com IN A]dnsname.zone.com IN A (dup ep)| [] | - // ------------------------------------------------------------------------------------------------------ - // - // Behavior on 0.13.6 on Deletes - // ------------------------------------------------------------------------------------------------------ - // DNSName | Current record | Desired Records (Candidate) | - // ------------------------------------------------------------------------------------------------------ - // dnsname.zone.com | [dnsname.zone.com IN CNAME ] | [] | - // ------------------------------------------------------------------------------------------------------ for _, current := range filterRecordsForPlan(p.Current, p.DomainFilter, p.ManagedRecords, p.ExcludeRecords) { t.addCurrent(current) @@ -266,11 +252,7 @@ func (p *Plan) Calculate() *Plan { // filter out updates this external dns does not have ownership claim over if p.OwnerID != "" { changes.Delete = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.Delete) - // Remove duplicated endpoints generated by plan.go on Line 210 - // changes.Delete = endpoint.RemoveDuplicates(changes.Delete) - // This was not needed on version 0.13.6, but it seems like - // the old function/code had the ability of removing duplicated endpoints - // While the filterRecordsForPlan and addCurrent functions were running + changes.Delete = endpoint.RemoveDuplicates(changes.Delete) changes.UpdateOld = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateOld) changes.UpdateNew = endpoint.FilterEndpointsByOwnerID(p.OwnerID, changes.UpdateNew) } From 519077750380a1a414fa0a46c583d20b46999d94 Mon Sep 17 00:00:00 2001 From: Leonardo Quatrocchi Date: Mon, 22 Apr 2024 20:58:22 -0300 Subject: [PATCH 22/22] Fix unrelated change on service_test.go address --- source/service_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/service_test.go b/source/service_test.go index d5472638a3..22633ed4b7 100644 --- a/source/service_test.go +++ b/source/service_test.go @@ -406,8 +406,8 @@ func testServiceSourceEndpoints(t *testing.T) { serviceTypesFilter: []string{}, resolveLoadBalancerHostname: true, expected: []*endpoint.Endpoint{ - {DNSName: "foo.example.org", RecordType: endpoint.RecordTypeA, Targets: endpoint.Targets{"93.184.216.34"}}, - {DNSName: "foo.example.org", RecordType: endpoint.RecordTypeAAAA, Targets: endpoint.Targets{"2606:2800:220:1:248:1893:25c8:1946"}}, + {DNSName: "foo.example.org", RecordType: endpoint.RecordTypeA, Targets: endpoint.Targets{"93.184.215.14"}}, + {DNSName: "foo.example.org", RecordType: endpoint.RecordTypeAAAA, Targets: endpoint.Targets{"2606:2800:21f:cb07:6820:80da:af6b:8b2c"}}, }, }, {