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

fix(plan): explicitly check for CNAME conflicts #3904

Closed
wants to merge 2 commits into from

Conversation

wbh1
Copy link
Contributor

@wbh1 wbh1 commented Sep 1, 2023

Description

This fixes a bug introduced in v0.13.5 (via this PR) in which CNAMEs are no longer treated as another candidate for the same DNS name. Instead, they are their own line in the plan and will always try to be created. Consequently, the plan can result in both A records (or others) and CNAMEs attempting to be created simultaneously, which results in errors.

Previously, it would put a CNAME and A record as candidates to the same domain (e.g. nginx.lke.hegedus.wtf), then ResolveCreate would choose which record to create (explicitly preferring A records as of #2716).

You can see how the data structure changed based on these screenshots from my debugger on v0.13.4 vs v0.13.5 (and main).

Old:
264868811-9a4e34f2-9cbc-4852-b896-3dd021bea8a2

New:
264868917-25fe2adb-56e8-498c-af4c-379ec748dc2e

Previously, just the DNS name was the key in the map, but now both the record type and the set identifier are considered part of the key.

Rather than reverting that change or further altering the data structure, I decided to implement the necessary CNAME safeguarding to avoid conflicting records. It feels gross to range over the same data structure multiple times like this, but it ought to always be small enough that it has a negligible impact on performance. Open to suggestions, though.

There are a lot of issues I've found related to trying to create CNAMEs instead of A records since v0.13.5. Some of the ones I found in passing that I think this might address:

Fixes #3714
Maybe #3833
Maybe #3787
Maybe #3706

This is another bug related to the data structure change to use planKey, but I don't think this solves it: #3715

Checklist

  • Unit tests updated
  • End user documentation updated

This fixes a bug introduced in v0.13.5 in which CNAMEs are no longer treated as
another candidate for the same DNS name. Instead, they are their own line in the plan and will always try to be created.
Consequently, the plan can result in both A records (or others) and CNAMEs
attempting to be created simultaneously, which results in errors.

Previously, this behavior was guaranteed by the IsLess function that would always
prefer an A or AAAA record over a CNAME for the same domain name. However, that
function rarely is reached anymore since you would need to have multiple candidates
for the same record type for it to trigger (e.g. 2 IP addresses for an A record).
Consequently, the behavior to prefer IP addresses is moot and needs to be addressed elsewhere (i.e. here).
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 1, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @wbh1. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 1, 2023
@wbh1
Copy link
Contributor Author

wbh1 commented Sep 1, 2023

This may already be covered by #3747, but perhaps @johngmyers or @cronik could speak to that.

@mloiseleur
Copy link
Contributor

Hello @wbh1,

Thanks for this PR. Would you please add a test to this PR ?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign njuettner for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 6, 2023
@johngmyers
Copy link
Contributor

This PR is unlikely to move forward as it duplicates #3747

@wbh1
Copy link
Contributor Author

wbh1 commented Sep 16, 2023

Closing in favor of #3747, which was merged.

@wbh1 wbh1 closed this Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

external-dns v0.13.5 trying to create CNAME records after upgrading leading to crashloopbackoff
4 participants