-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Multitarget #376
Multitarget #376
Conversation
…t rather than just per DNSName
… state rather than Endpoint.Labels
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I signed |
62212f0
to
28fec84
Compare
Bump for CLAbot 🤞 |
updateOld/-New can only be used to update an existing record without changing its identifying information, i.e. name and target. so instead of updateOld: foo.com => 1.1.1.1, updateNew: foo.com => 2.2.2.2 one must: delete: foo.com => 1.1.1.1, create: foo.com => 2.2.2.2
…t an owner record
Target: "8.8.8.8", | ||
DNSName: "update-record", | ||
Target: "8.8.4.4", | ||
RecordTTL: 50, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test only work with TTL?
I think we should have a default defined in the zone, similar to DNS origin definition to default TTLs.
If it works, can we make this testcase to have with and without TTL tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TTLs are there in some tests now to have record updates rather than creations/deletions. Basically, with one Endpoint per (DNSName, Target), to update a record rather than delete it and create another one, you must not change either DNSName or Target, so I'm changing the TTL instead. If you change the target, the record won't be updated, it will be deleted and another one with the new target created -- similar to what would happen if you change the name. I have modified Plan.Calculate() to operate this way. (that's really the crux of this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks to clarify this
Pretty clean code from scrolling over, thanks for this PR. |
👍 |
shouldUpdateTTL := shouldUpdateTTL(desired, current) | ||
|
||
if !targetChanged && !shouldUpdateTTL { | ||
if !shouldUpdateTTL { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition skipped the record in case nothing was changed (target nor TTL). With this it skips the record whenever TTL was changed (but target could have) which seems wrong to me. Can you double-check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desired
and current
are guaranteed to have the same target (see the recordExists() modification below), so targetChanged would always be false. That's why I removed it. As I said, with this PR you'd have one Endpoint
per DNSName and Target rather than just per DNSName, so if the target changes, the corresponding endpoint will be removed and a new one with the same name and the new target created. So it treats target changes just like it always treated name changes -- the old Endpoint will be removed and a new one created. The TTL would be the only remaining thing in an Endpoint that can actually "change".
That's really the crux of this PR -- don't turn Endpoint.Target
into an array, instead have one Endpoint per name and target. I did this because I figured it would require fewer (possibly no) changes to the providers, and I wanted to get the CF provider up and running with multiple targets quickly (I initially thought you'd basically get away with just changing plan.recordExists(), then saw that I should also modify the ownerId tracking in TXTRegistry). I guess we'd have to discuss whether this is the best way forward or not, since this is obviously incompatible with the other multitarget PRs that turn Endpoint.Target
into an array.
Since I am very interested in supporting multiple targets for a single DNS name and I was intrigued by the idea to keep changes in providers to a minimum, I tried to adapt this PR for our environment. We are using Google Cloud DNS on GKE. |
@dereulenspiegel the idea is to go with the Endpoint.Target to array transition. Personally I would prefer to immediately go with that solution which would work for all providers (presumably). Please refer to: #396, #404 it gives some context on how we are planning to enable multi-target support |
I agree that one endpoint per target is probably not the best general solution, and I certainly don't cling to it or anything. It was just something to get going quickly on CF. |
@ideahitme I already read #396 and #404 . But I thought I will try this idea, to a) provide some feedback on another provider than the one used by the creator of this PR and b) have short term solution for our cluster, since #404 seems to need a bit more time. |
@dereulenspiegel yes, feedback would be awesome. However, based on my analysis, #404 should be safe for rollout in any dns-provider, however I only tested it on AWS. I am afraid any short term solution have to also fix internal component logic (plan) (in a fashion similar to #404), I could be wrong though. I am basically waiting for #404 to be reviewed and need additional pair of eyes to make sure it is correct approach, but from coding perspective it should be complete |
Multi-target functionality has successfully landed in another PR. Therefore I'm closing this. Feel free to re-open if you think it's wrong. Thanks @multi-io for all your effort! |
This PR enables having multiple targets per domain name. I'm aware of PR 243, but this one works by having one
Endpoint
structure per (name, target) rather than extendingEndpoint.Target
to be an array and having oneEndpoint
per name. This means that the existing providers should work without changes, EXCEPT if they're written explicitly with the assumption of one endpoint per name in mind. We're using the Cloudflare provider; I had to modify one line (2d45bc2) to make it work. I also modified the inmemory provider accordingly and added multi-target tests to for TXTRegistry, Controller and Plan.I modified
TXTRegistry
to perform the ownerID tracking internally by caching some state in member variables betweenRecords()
andApplyValues()
, rather than using the Endpoints'.Labels["owner"]
for that (storing per-name ownerIDs in per-target Endpoints would've been redundant and would've complicated things). This means that the labels are no longer used for anything now and might be removed unless we need them for something else in the future.Everything works, AFAICS. We use the CF provider as I said, haven't really tested the others.
(update 11/08/17: inmemory provider multi-target capability, more tests)