Skip to content

fix(aws): incorrect behavior for non-aliasable record types#6017

Merged
k8s-ci-robot merged 14 commits into
kubernetes-sigs:masterfrom
u-kai:fix/aws-alias-logic
May 3, 2026
Merged

fix(aws): incorrect behavior for non-aliasable record types#6017
k8s-ci-robot merged 14 commits into
kubernetes-sigs:masterfrom
u-kai:fix/aws-alias-logic

Conversation

@u-kai
Copy link
Copy Markdown
Member

@u-kai u-kai commented Dec 12, 2025

What does it do?

This PR fixes incorrect behavior for record types that do not support AWS Alias records (e.g., MX, TXT, SRV, etc.).

Motivation

This work originated from the discussion here:
#5997 (comment)

When a ProviderSpecific property alias=true exists on record types that don't support alias records
(like MX records):

  • Alias processing continues even after alias property deletion
    • The alias property is deleted at aws.go, but the alias variable remains true
    • This results in unnecessary evaluateTargetHealth=false being added
  • TTL value gets unintentionally modified
    • When RecordTTL is configured, it gets fixed to 300

Reproduction

ep := &endpoint.Endpoint{
    RecordType: endpoint.RecordTypeMX,
    RecordTTL:  600,
    ProviderSpecific: endpoint.ProviderSpecific{
        {Name: "alias", Value: "true"},
    },
}
// Expected: TTL=600, ProviderSpecific=empty
// But result is: TTL=300, evaluateTargetHealth=false gets added

While this affects cases with incorrectly configured ProviderSpecific properties, I believe the behavior should

More

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

Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added the internal Issues or PRs related to internal code label Dec 12, 2025
@k8s-ci-robot k8s-ci-robot added provider Issues or PRs related to a provider needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 12, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @u-kai. Thanks for your PR.

I'm waiting for a github.com 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.

Details

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 12, 2025
@u-kai u-kai changed the title Refactor alias-handling logic and fix incorrect behavior for non-aliasable record types fix(aws): refactor alias-handling logic and fix incorrect behavior for non-aliasable record types Dec 12, 2025
@ivankatliarchuk
Copy link
Copy Markdown
Member

Refactoring and bug fix in single PR. Too risky. As well as for bug, it should be manifests provided to reproduce

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Dec 12, 2025

@ivankatliarchuk
Sorry about that — I’ll be more careful next time.

To make the existing issue easier to fix, I’ve opened a separate PR with the refactoring work.
Once that PR is merged, I will rebase this PR and continue the bug fix on top of it.

It would be great if you could review the refactoring PR first. Thanks!

@u-kai u-kai changed the title fix(aws): refactor alias-handling logic and fix incorrect behavior for non-aliasable record types fix(aws): rfix incorrect behavior for non-aliasable record types Dec 12, 2025
@u-kai u-kai changed the title fix(aws): rfix incorrect behavior for non-aliasable record types fix(aws): incorrect behavior for non-aliasable record types Dec 12, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2026
u-kai added 2 commits January 28, 2026 21:55
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 28, 2026
@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Jan 28, 2026

@ivankatliarchuk
Now that the refactoring PR has been merged, I’ve rebased and updated this PR so it’s ready for review again.

@ivankatliarchuk
Copy link
Copy Markdown
Member

Missing links to docs in description with facts about this behaviour. Missing end to end tests with the proof.

I'll review only after other reviewers share their review. I could not keep approving on my own.

@ivankatliarchuk
Copy link
Copy Markdown
Member

There’s no example showing the current behaviour, so it’s unclear whether this is actually a problem or not.

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Jan 28, 2026

I’ve updated the PR description.

Previously, even for record types that do not support alias (such as MX records), ExternalDNS was applying alias-specific behavior — updating TTL and adding the evaluateTargetHealth property — whenever alias was set to true.

This was incorrect and also hurt code readability.
With this change, MX records no longer have their TTL modified even if alias is true, and alias-related properties are removed for record types that do not support alias.

@ivankatliarchuk
Copy link
Copy Markdown
Member

Missing before and after real example. And missing links to official documentation describing AWS alias record behavior

@ivankatliarchuk
Copy link
Copy Markdown
Member

Now:

  • AWS provider silently “fixes” invalid alias usage
  • Other providers may not
  • Behavior diverges across providers

ExternalDNS should enforce provider-agnostic semantics before provider code runs.

@ivankatliarchuk
Copy link
Copy Markdown
Member

Ideally, what we should have

Reject invalid combinations at middleware layer:

  • alias=true only allowed for A / AAAA
  • fail endpoint validation
  • surface a clear debug msg

This is the cleanest contract.

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Feb 11, 2026

Totally agree — the issue here is the responsibility boundary.

To move in that direction, I opened a follow-up PR that makes endpoint validation fail when alias=true is used for non A/AAAA,CNAME record types. Once that PR is merged, this PR can be simplified further.

I’ll update this PR accordingly once the validation change lands.

u-kai added 2 commits March 1, 2026 10:33
@ivankatliarchuk
Copy link
Copy Markdown
Member

Is this resolved or still a problem?

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Mar 4, 2026

Sorry, it has already been resolved.

@ivankatliarchuk
Copy link
Copy Markdown
Member

Sorry, it has already been resolved.

/close

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@ivankatliarchuk: Closed this PR.

Details

In response to this:

Sorry, it has already been resolved.

/close

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.

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Mar 31, 2026

Sorry for the confusion. "Resolved" was referring to the code review comment being addressed, not the PR itself being resolved. I'll reopen this.

@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Mar 31, 2026

/reopen

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@u-kai: Reopened this PR.

Details

In response to this:

/reopen

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 reopened this Mar 31, 2026
@ivankatliarchuk
Copy link
Copy Markdown
Member

Ok

Copy link
Copy Markdown
Member

@ivankatliarchuk ivankatliarchuk left a comment

Choose a reason for hiding this comment

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

I think the change missing some links in PR title + debug logs or something.

High level. We have a gap - no end 2 end test that stitches together CheckEndpoint → dedupSource → AdjustEndpoints to show the full rejection path. The two unit tests exist, but their composition is not visible in unit tests.

Comment thread provider/aws/aws.go
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we cleaning up the providerSpecificAlias property in wrapper layer? This was just added in recent PR https://github.com/kubernetes-sigs/external-dns/pull/6021/changes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've separated this into the PR below:
#6342

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

PR has merged! thanks!

Comment thread provider/aws/aws_test.go
expectedAaaa: nil,
},
// TODO: fix For records other than A, AAAA, and CNAME, if an alias record is set, the alias record processing is not performed. This will be fixed in another PR.
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure. Maybe instead of removing test, actually provide a current code behaviour with changed name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right that this case can still exist from a unit test perspective.
However, in the current design, it's difficult for an alias record to be used with MX, since it's prevented at another layer, so I removed the test.

What kind of test name would you suggest if we keep it?

Comment thread provider/aws/aws_test.go Outdated
@u-kai
Copy link
Copy Markdown
Member Author

u-kai commented Apr 22, 2026

The links and before/after examples are already included in the comments above.

Regarding E2E tests:
I agree it would be valuable, but I'd prefer to track it as a follow-up rather than blocking this fix.

@ivankatliarchuk
Copy link
Copy Markdown
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 3, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ivankatliarchuk

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

The pull request process is described here

Details 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 3, 2026
@ivankatliarchuk
Copy link
Copy Markdown
Member

e2e #6017 (comment)

@k8s-ci-robot k8s-ci-robot merged commit ddd2cc3 into kubernetes-sigs:master May 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. internal Issues or PRs related to internal code lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. provider Issues or PRs related to a provider 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.

4 participants