Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh49 distributed dns plan #79

Merged
merged 4 commits into from
Apr 20, 2024
Merged

Conversation

mikenairn
Copy link
Member

@mikenairn mikenairn commented Apr 15, 2024

closes #49 #85

Initial work to modify the external-dns plan to work in the proposed way for distubuted dns.

Updates the plan to treat all endpoints passed to it (current/desired) as part of a single shared set of records. The calculation logic now takes into account other endpoints added to the plan when calculating the desired changes for any other endpoint also added.

The plan calculation logic is broken into two steps:

  1. Calculate what endpoints will be created/updated and deleted based on the current and desired records passed to the plan. For each endpoint that will still exist if these changes were to be applied(create/update), a map of dnsNames and their owners is calculated.

  2. Create the external-dns Changes for the endpoints calculated in step one. For all endpoints calculated to be an update the target values are re-calculated using the information gathered in step one about ownership of dnsNames. If we detect that a CNAME has a "managed" target value (it's in our owner map) we use the information known about who owns it to manipulate the desired targets values.

@mikenairn mikenairn changed the title WIP Gh49 multi cluster plan WIP Gh49 distuibuted dns plan Apr 15, 2024
@mikenairn mikenairn changed the title WIP Gh49 distuibuted dns plan WIP Gh49 distributed dns plan Apr 15, 2024
if len(row.current) > 0 && len(row.candidates) == 0 {
changes.Delete = append(changes.Delete, row.current...)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took me a while to get this in my head. Might be worth a bit more of a comment? So basically I see this controller removing itself as an owner of this endpoint and if no other owners deleting otherwise updating the record

@mikenairn mikenairn force-pushed the GH49_multi_cluster_plan branch 3 times, most recently from 33908bc to 0add671 Compare April 16, 2024 08:48
Copy link
Collaborator

@maleck13 maleck13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok made a first pass. I have some understanding of what this is doing now. But can't say I know enough at this point to say it right or wrong I guess. I wil give it another pass later today

@mikenairn mikenairn force-pushed the GH49_multi_cluster_plan branch 4 times, most recently from 1c80038 to 244f858 Compare April 18, 2024 16:26
Initial work to modify the external-dns plan to work in the proposed way
for distubuted dns.

Updates the plan to treat all endpoints passed to it (current/desired)
as part of a single shared set of records. The calculation logic now
takes into account other endpoints added to the plan when calculating
the desired changes for any other endpoint also added.

The plan calculation logic is broken into two steps:

1. Calculate what endpoints will be created/updated and deleted based on
   the current and desired records passed to the plan. For each endpoint
that will still exist if these changes were to be
applied(create/update), a map of dnsNames and their owners is
calculated.

2. Create the external-dns Changes for the endpoints calculated in
   step one. For all endpoints calculated to be an update the target
values are re-calculated using the information gathered in step one
about ownership of dnsNames. If we detect that a CNAME has a "managed"
target value (it's in our owner map) we use the information known about
who owns it to manipulate the desired targets values.
Prevent the switch of CNAME records to Alias A records for CNAMES with
an aws ec2 loadbalancer as the target.  Prevent evaluate target health
automatically being applied to alias targets (Not strictly required
since we don't create any now but turning it off anyway)
@mikenairn mikenairn force-pushed the GH49_multi_cluster_plan branch from 244f858 to 0dd544b Compare April 19, 2024 08:59
@mikenairn mikenairn marked this pull request as ready for review April 19, 2024 09:10
@mikenairn mikenairn changed the title WIP Gh49 distributed dns plan Gh49 distributed dns plan Apr 19, 2024
Update the plan to keep track of conflicts it can't resolve. It stores
each conflict as an error in an array that can be queried later before
applying changes. The plan will currently create a conflict error if the
record type of an endpoint is going to change, or an attempt to update a
record that is owned or unowned by one that is unowned or owned (The
opposite).
@@ -365,6 +366,10 @@ func (r *DNSRecordReconciler) applyChanges(ctx context.Context, dnsRecord *v1alp

plan = plan.Calculate()

if err = plan.ConflictError(); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice so conflicts in this pr now also

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when i was writing the issue for it (#85), i was looking into the best way to do it and pretty much just did it, so carried on. Kept it fairly simple anyway, just collect errors and expose them from the plan to query later.

Was thinking this morning i might make it more generic so we can just add all types of possible errors to it. We can use it for the missing managed record errors we want for the likes of default geo etc..

@@ -159,4 +165,75 @@ var _ = Describe("DNSRecordReconciler", func() {
}, TestTimeoutLong, time.Second).Should(Succeed())
})

It("should not allow second record to change the type", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@maleck13 maleck13 added this pull request to the merge queue Apr 20, 2024
Merged via the queue into Kuadrant:main with commit a3eaacf Apr 20, 2024
9 checks passed
@mikenairn mikenairn deleted the GH49_multi_cluster_plan branch April 22, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement multi cluster plan and registry
2 participants