@@ -21,6 +21,7 @@ import (
21
21
"errors"
22
22
"fmt"
23
23
"net"
24
+ "slices"
24
25
"strings"
25
26
"time"
26
27
@@ -700,9 +701,12 @@ func (r *DNSRecordReconciler) applyLocalChanges(ctx context.Context, dnsRecord *
700
701
// update flow
701
702
702
703
}
703
- mergeCopy .Spec .Endpoints = endpointSet
704
- if err := r .Client .Update (ctx , mergeCopy , & client.UpdateOptions {}); err != nil {
705
- return fmt .Errorf ("failed to update core dns merged copy %w" , err )
704
+ if ! endPointsEqual (mergeCopy .Spec .Endpoints , endpointSet ) {
705
+ logger .Info ("updating merged copy with new endpoints" + mergeCopy .Name )
706
+ mergeCopy .Spec .Endpoints = endpointSet
707
+ if err := r .Client .Update (ctx , mergeCopy , & client.UpdateOptions {}); err != nil {
708
+ return fmt .Errorf ("failed to update core dns merged copy %w" , err )
709
+ }
706
710
}
707
711
return nil
708
712
}
@@ -735,10 +739,15 @@ func (r *DNSRecordReconciler) applyLocalChanges(ctx context.Context, dnsRecord *
735
739
}
736
740
}
737
741
//update endpoints only
738
- kdrntLocalCopy .Spec .Endpoints = computeLocalEndpointSet (original )
739
- if err := r .Client .Update (ctx , kdrntLocalCopy , & client.UpdateOptions {}); err != nil {
740
- return fmt .Errorf ("failed to update kuadrant local copy %w" , err )
742
+ computedEndpoints := computeLocalEndpointSet (original )
743
+ if ! endPointsEqual (kdrntLocalCopy .Spec .Endpoints , computedEndpoints ) {
744
+ logger .Info ("updating local endpoints for record " + kdrntLocalCopy .Name )
745
+ kdrntLocalCopy .Spec .Endpoints = computedEndpoints
746
+ if err := r .Client .Update (ctx , kdrntLocalCopy , & client.UpdateOptions {}); err != nil {
747
+ return fmt .Errorf ("failed to update kuadrant local copy %w" , err )
748
+ }
741
749
}
750
+
742
751
return nil
743
752
}
744
753
@@ -773,6 +782,23 @@ func (r *DNSRecordReconciler) applyLocalChanges(ctx context.Context, dnsRecord *
773
782
return hadChanges , []string {}, nil
774
783
}
775
784
785
+ func endPointsEqual (eps1 , eps2 []* externaldnsendpoint.Endpoint ) bool {
786
+ return slices .EqualFunc (eps1 , eps2 , func (e1 , e2 * externaldnsendpoint.Endpoint ) bool {
787
+ if e1 .DNSName != e2 .DNSName {
788
+ return false
789
+ }
790
+
791
+ if ! e1 .Targets .Same (e2 .Targets ) {
792
+ return false
793
+ }
794
+ if ! slices .Equal (e1 .ProviderSpecific , e2 .ProviderSpecific ) {
795
+ return false
796
+ }
797
+
798
+ return true
799
+ })
800
+ }
801
+
776
802
// applyExternalDNSChanges creates the Plan and applies it to the registry. This is used only for external cloud provider DNS. Returns true only if the Plan had no errors and there were changes to apply.
777
803
// The error is nil only if the changes were successfully applied or there were no changes to be made.
778
804
func (r * DNSRecordReconciler ) applyExternalDNSChanges (ctx context.Context , dnsRecord * v1alpha1.DNSRecord , probes * v1alpha1.DNSHealthCheckProbeList , dnsProvider provider.Provider , isDelete bool ) (bool , []string , error ) {
0 commit comments