Skip to content

fix(crd): txt record deletion #5280

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arontsang
Copy link

Description

Adds support for deleting TXT records after the CRD is deleted.

Fixes #5254
Fixes #5279

Checklist

  • Unit tests updated
  • End user documentation updated

Copy link

linux-foundation-easycla bot commented Apr 12, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@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 szuecs for approval. For more information see the 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 added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 12, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @arontsang!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 12, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @arontsang. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 12, 2025
@mloiseleur
Copy link
Collaborator

Thanks for this @arontsang 👍
Do you think you can add some tests on this ?

@arontsang
Copy link
Author

arontsang commented Apr 13, 2025 via email

@ivankatliarchuk
Copy link
Contributor

Could you explain a little more what this code suppose to be doing? I do not understand it

@arontsang
Copy link
Author

arontsang commented Apr 14, 2025

Sure @ivankatliarchuk

The bug.

https://github.com/kubernetes-sigs/external-dns/blob/master/registry/txt.go#L198 is failing to apply the labels for TXT records to the TXT endpoints.

The result.

https://github.com/kubernetes-sigs/external-dns/blob/master/controller/controller.go#L255 plan.Calculate() regards any TXT records created by external-dns as not being created by external-dns (missing owner etc etc).

The cause.

a) Old style TXT records come in on the same record as the target

foo.acme.com TXT value [ 'FOOBAR', 'heritage=external-dns,....blah' ]

Depending on which value is returned first, we end up with two different but equally broken behaviors.

  • We detect the record is an endpoint, but are missing the label
  • We detect the label, but have no endpoint to apply it to....:(

Therefore we need to disable the creation of old style TXT records for TXT endpoints.
https://github.com/kubernetes-sigs/external-dns/blob/master/registry/txt.go#L240

Also disable fallback to old style when annotating TXT endpoints.
https://github.com/kubernetes-sigs/external-dns/blob/master/registry/txt.go#L199

b) New style TXT records are not recognized as being the heritage for the endpoint, because getSupportedTypes() is hard coded to NOT allow support for new style TXT records.
https://github.com/kubernetes-sigs/external-dns/blob/master/registry/txt.go#L111

Ideally, someone updates this code to use the --managed-record-types options to drive this code. But that is well beyond my abilities with golang.

@ivankatliarchuk
Copy link
Contributor

I will try to give it another shot. But from my integration tests it does not work. The whole issue is, we support legacy and new formats, as a result the TXT handling is not properly supported.

Have you tried to do end-2-end testing and it works on your side?

@ivankatliarchuk
Copy link
Contributor

I've added comment in the issue #5254 (comment)

@arontsang
Copy link
Author

I was debugging with a local cluster/docker with my own cloudflare account.

Seems to work well with deleting TXT records.

@arontsang
Copy link
Author

I also know that if the user has A/AAAA/CNAME records with the same name as the TXT records you are trying to create, my PR will not work.

It ONLY works with the case where TXT names are different from the other records, OR "only new TXT" is enabled.

Again, ideally, we inject the --managed-record-types values into getSupportedTypes.

I suggested both that, and a change where --managed-record-types=TXT requires that --txt-new-format-only is also switch on.

PS, did you test the change with --managed-record-types=TXT?

@ivankatliarchuk
Copy link
Contributor

Indeed. It does not seems like CRD is care at all about this config. Seems like you have some other manifest that generates TXT record. As CRD simply does not support TXT from the code itself.

@ivankatliarchuk
Copy link
Contributor

I suggested both that, and a change where --managed-record-types=TXT requires that --txt-new-format-only is also switch on.

This is it. The problem with TXT formats. There is a PR to simplify logic, #5172 but most likely is not going into master anytime soon (in fact I'm planning to close it, as there are pushbucks and folks happy to have this TXT mess). CRD and TXT is a problem for long time.

Share all manifests. I could try once again. I'm testing on staging accounts where I have thousands of TXT recrods, not on fresh/empty

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 26, 2025
@arontsang arontsang force-pushed the feature/support-txt-records branch from 44892d3 to c1a18f3 Compare April 26, 2025 08:30
@arontsang
Copy link
Author

hey @ivankatliarchuk
I've updated my PR to fix the logic in the TXT record handling.

Previously it was assumed that a TXT records is either a heritage/label entry, OR a TXT entry.

We would only process the FIRST txt target for a TXT record into a label.

I've now changed the logic to process ALL targets as labels, and then process the rest as a TXT entry.

This means that we can use old style txt format with A/AAAA records together.
It should also mean that TXT should work correctly now.

@mloiseleur
Copy link
Collaborator

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 4, 2025
@arontsang arontsang force-pushed the feature/support-txt-records branch 2 times, most recently from dbfbd31 to c6653e0 Compare May 5, 2025 15:24
@arontsang arontsang force-pushed the feature/support-txt-records branch from c6653e0 to cb58622 Compare May 5, 2025 15:37
@mloiseleur
Copy link
Collaborator

/retitle fix(crd): txt record deletion

@k8s-ci-robot k8s-ci-robot changed the title Add support for TXT record type fix(crd): txt record deletion May 7, 2025
@mloiseleur
Copy link
Collaborator

@ivankatliarchuk anything left on your side ?
@mcharriere @mrozentsvayg Do you think one of you can proceed with a final review ?

@ivankatliarchuk
Copy link
Contributor

I could not approve. Both issues do not click to me. Overall I understand the direction, to have a better integration most likely with cert-manager or smth.

From the code perspective it's seems like a breaking change. We use to process first Target, now we process all record targets.

No integration tests before and after, unit tests not updated to cover a case.

@ivankatliarchuk
Copy link
Contributor

Let's keep it open. I'll asked one of the team working with to try on some close to real clusters. May takes few weeks

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
4 participants