Skip to content

Conversation

u-kai
Copy link
Contributor

@u-kai u-kai commented Oct 8, 2025

What does it do ?

This PR fixes an issue where stale TXT record information could remain when ApplyChanges was not called.
Previously, existingTXTs were only reset via a defer inside ApplyChanges, but when plan.Changes.HasChanges() was false (i.e., no DNS changes to apply), that method was skipped, and the cached TXT records were not cleared.

This change ensures that existingTXTs are always reset, so the latest TXT record state is correctly reflected in subsequent reconciliation loops.

Motivation

When ExternalDNS detected no DNS changes (plan.Changes.HasChanges() == false), ApplyChanges was skipped and the existingTXTs reset logic inside it was not executed.
As a result, outdated TXT record information could persist and cause ExternalDNS to skip creating new TXT records for newly created A/AAAA records.

By resetting existingTXTs every time (even when there are no changes), we ensure that TXT ownership information always stays in sync with the current state in Route53.

Fixes: #5894

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. registry Issues or PRs related to a registry labels Oct 8, 2025
@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 Oct 8, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @u-kai. 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 the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 8, 2025
@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 Oct 8, 2025
@u-kai u-kai changed the title WIP:fix(txt-register): reset existingTXTs even when ApplyChanges is skipped to avoid stale TXT records fix(txt-register): reset existingTXTs even when ApplyChanges is skipped to avoid stale TXT records Oct 8, 2025
@u-kai u-kai marked this pull request as ready for review October 8, 2025 23:27
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 8, 2025

}

// TestRecreateRecordAfterDeletion ensures that when A and TXT records are deleted,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I confirmed that this test failed on previous versions with the following output:

kai@kainoMacBook-Pro external-dns % go test ./registry/...
--- FAIL: TestRecreateRecordAfterDeletion (0.00s)
    txt_test.go:2190:
                Error Trace:    /Users/kai/external-dns/registry/txt_test.go:2190
                Error:          Should be true
                Test:           TestRecreateRecordAfterDeletion
                Messages:       Expected records after reconciliation: [bar.test-zone.example.org 0 IN A  1.2.3.4 [] a-bar.test-zone.example.org 0 IN TXT  "heritage=external-dns,external-dns/owner=foo" []], but got: [bar.test-zone.example.org 0 IN A  1.2.3.4 []]
FAIL
FAIL    sigs.k8s.io/external-dns/registry       0.345s
FAIL

@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 Oct 9, 2025
@szuecs
Copy link
Contributor

szuecs commented Oct 9, 2025

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 9, 2025
@u-kai
Copy link
Contributor Author

u-kai commented Oct 10, 2025

@szuecs @mloiseleur
Thank you for the approval.
I believe the failing test in CI has already been fixed and merged into the main branch.
Since the PR has been approved, would you recommend that I pull the latest changes from main, or would it be better to have the CI job restarted?

@mloiseleur
Copy link
Collaborator

@u-kai You need to rebase on master branch, then the CI will pass green.

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2025
@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 ask for approval from szuecs. 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 removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 13, 2025
@u-kai
Copy link
Contributor Author

u-kai commented Oct 13, 2025

@mloiseleur @szuecs

I’ve merged the latest changes from the master branch.
Please take another look.

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. registry Issues or PRs related to a registry 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.

First creation of record only generates 1 A record, second creation generates 1 A record + 1 TXT record

4 participants