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 PowerDNS regex domain filter #3828

Closed

Conversation

matusf
Copy link
Contributor

@matusf matusf commented Jul 31, 2023

Description
Regex domain filter stopped working because MatchParent method was invoked during zone partitioning. The failure occured because MatchParent included wrong zones (zones not matcing the regex) in the filtered list. Subsequently listing of those zones failed because the pdns client did not have api token with permissions to list them.

To fix this issue I disabled MatchParent functionality when matching domain using regex domain filter because MatchParent is a specific "extension" of domain filter.

Fixes #3816

Checklist

  • Unit tests updated
  • End user documentation update

@k8s-ci-robot
Copy link
Contributor

Welcome @matusf!

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 Jul 31, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @matusf. 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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 31, 2023
Copy link
Contributor

@mloiseleur mloiseleur left a comment

Choose a reason for hiding this comment

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

It's a missing a test on domain_filter, to ensure this issue won't happen again.

docs/tutorials/pdns.md Outdated Show resolved Hide resolved
@matusf
Copy link
Contributor Author

matusf commented Aug 1, 2023

It's a missing a test on domain_filter, to ensure this issue won't happen again.

@mloiseleur, shall I test that MatchParent returns false if the regex domain filter is set? The Match function returned correct results even before this fix. The issue was that PowerDNS provider always calls MatchParent if Match fails (here).

@mloiseleur
Copy link
Contributor

@matusf Then ... 🤔 why don't you remove the invalid call on PowerDNS provider, then ?

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 1, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. 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 Aug 1, 2023
@matusf matusf force-pushed the fix/pdns-regex-domain-filter branch from 1c58966 to ea51373 Compare August 1, 2023 14:57
@matusf matusf marked this pull request as draft August 1, 2023 15:39
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 1, 2023
@matusf matusf force-pushed the fix/pdns-regex-domain-filter branch from ea51373 to 9272943 Compare August 1, 2023 16:06
@matusf matusf marked this pull request as ready for review August 1, 2023 16:07
@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 Aug 1, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 2, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: matusf, mloiseleur
Once this PR has been reviewed and has the lgtm label, please assign seanmalloy 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

@matusf
Copy link
Contributor Author

matusf commented Aug 2, 2023

/retest-required
Running retest required to rerun failed test. the test failed because of missing golangci-lint. This PR did not change anything regarding golangci-lint, so it may be a flaky test.

@k8s-ci-robot
Copy link
Contributor

@matusf: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required
Running retest required to rerun failed test. the test failed because of missing golangci-lint. This PR did not change anything regarding golangci-lint, so it may be a flaky test.

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.

@matusf
Copy link
Contributor Author

matusf commented Aug 2, 2023

/cc @johngmyers @njuettner
Hi, could you please review my changes?

@mloiseleur
Copy link
Contributor

@matusf The CI has been fixed with #3829. If you rebase this PR, CI should be able to pass as expected.

This test is expected to fail and aims to show that regex domain filter
is not working.
@matusf matusf force-pushed the fix/pdns-regex-domain-filter branch from 9272943 to 0df91c4 Compare August 5, 2023 15:50
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2023
@matusf
Copy link
Contributor Author

matusf commented Aug 5, 2023

Thanks @mloiseleur, I rebased.

@mloiseleur
Copy link
Contributor

/lgtm
/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. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 5, 2023
Copy link
Contributor

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

Why are we putting the check for being a regex filter in the caller? Shouldn't it be in MatchParent like it is in Match? Then we wouldn't have to make IsRegexFilterConfigured public.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2023
@matusf
Copy link
Contributor Author

matusf commented Aug 6, 2023

Firstly I put the check in the MatchParent function but then mloiseleur suggested to put it in a caller.

@johngmyers
Copy link
Contributor

That's not how I interpreted that comment. I interpret it as asking why pdns is calling MatchParent at all. Perhaps @mloiseleur could clarify.

@mloiseleur
Copy link
Contributor

That's not how I interpreted that comment. I interpret it as asking why pdns is calling MatchParent at all.

Yes, exactly. It seems weird to have only pdns calling MatchParent. I have not (yet) understood why it's called.

@matusf
Copy link
Contributor Author

matusf commented Aug 7, 2023

The MatchParent functions matches a zone if the zone is a parent zone of the filter. This functionality is only enabled in pdns provider. The implementation is a bit unfortunate, since now pdns diverges from other providers. It caused issues like breaking domain filter when trying to match one zone #3822.

For example --domain-filter=example.com will fail to match zone example.com in pdns provider (because it calls MatchParent and one might not have pdns api key with permissions for the parent zone), but it will work with every other provider (because it will not call MatchParent).

To disable this behaviour, one needs to prefix the filter with dot .. But this does not work as well because Match function treats the dot as a part of the filter and not as a "flag" to disable matching parent. As a result domain filter is broken for pdns as well.

I would suggest removing the MatchParent functionality, bacause as I said, it breaks existing filters, makes pdns behave differently than any other provider even though they have the same configuration, and the MatchParent functonality can be replaced by specifying multiple domain filters. It is also used by only one provider. I would volunteer to make this change.

Another approach might be to create a new cli flag to enable the match parent functionality and do not piggyback on the domain filter. This would also solve the abovementioned challenges.

@mhanc
Copy link

mhanc commented Aug 11, 2023

Hello, thanks for the analysis @matusf . I can confirm, that removing the MatchParent function would resolve #3822 (while making the pdns provider work the same as the rest of providers).

@mloiseleur
Copy link
Contributor

@matusf @mhanc I agree with you. We should remove this MatchParent functionnality and align this provider with the others.

@matusf
Copy link
Contributor Author

matusf commented Aug 11, 2023

Ok, shall I remove it as part of this PR (and thereby fix the regex domain filter)?

@johngmyers
Copy link
Contributor

I suppose there isn't a good way to mark MatchParent as deprecated.

I wouldn't oppose removing the functionality. We'd have to announce the behavior change in the relevant release.

@matusf
Copy link
Contributor Author

matusf commented Aug 14, 2023

I created new PR (#3869) which supersedes this one. It deletes the MatchParent functionality.

@mloiseleur
Copy link
Contributor

/close

@k8s-ci-robot
Copy link
Contributor

@mloiseleur: Closed this PR.

In response to this:

/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/test-infra repository.

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
Development

Successfully merging this pull request may close these issues.

PowerDNS regex domain filter stopped working
5 participants