-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
plugin/forward: Enable multiple forward declarations #5127
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5127 +/- ##
==========================================
+ Coverage 55.70% 56.99% +1.29%
==========================================
Files 224 236 +12
Lines 10016 14806 +4790
==========================================
+ Hits 5579 8439 +2860
- Misses 3978 5855 +1877
- Partials 459 512 +53
Continue to review full report at Codecov.
|
FWIW - A case came up again in a recent support issue, where allowing multiple forward declarations in the root server block would enable a better solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisohaver could you extend README of forward plugin and add mention that this plugin can be specified multiple times in a single server block (thats not common pattern in CoreDNS => worth mentioning in README), what is the behaviour in such case and maybe some usecases? Also please add an example into the README of Corefile with multiple forward declarations?
Thanks for reviewing!
Actually, it is a common pattern in CoreDNS, but worth illustrating with an example. I think plugins that enforce only one per server block are the exception, hence those plugins having a note in their README, "This plugin can only be used once per Server Block."
Agreed. I will add an example that illustrate a use case for multiple instances. |
0737946
to
26a9df2
Compare
@Tantalor93, It's been a looong time since I looked at this (January). I want to build it and play with it a bit to make sure it works as intended before merging. |
OK, I have tested using local forwarding and the forwarding aspect works as expected. I've also added a note about plugin order in the Corefile, since (as is the case in some other multi-instance plugins) relative order of the instances in the server block matters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed that parseForward
is not used anymore in production code (it is replaced by parseMultiForward
), could you remove it?
IIRC it is used by the alternate external plugin. So for now, I was going to leave it in. |
Hmm. Maybe not that plugin, but I thought an external plugin used it? I should have commented why I left it in. This PR had been sitting waiting for a review for so long I forgot the details. Thanks for dedicating the time to reviewing PRs! |
I think that
no problem, this feature looks very useful 👍 |
it couldn’t have been used by another package because it’s a private function. Oh. I think I remember why I thought this. I think it was once a public function, and it was used by an external plugin, but later it was made private in a refactor, breaking the plugin. And the other plugin was refactored. TLDR, I can remove it. |
@Tantalor93, How do I interpret the linter failure? It says there exists trailing whitespace but doesn't say where. |
2f3ca52
to
acabf6f
Compare
rebasing, to see if that helps the cryptic linter fail... no it didnt. |
I think I figured it out - golinter makes comments in-line in the commits. |
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver <[email protected]>
acabf6f
to
37c45c0
Compare
@chrisohaver yea, golangci-lint annotates code directly (see golangci/golangci-lint-action#5) |
Yeah - weird that those comments don't show up in the main discussion. That means for a large commit, you'd have to go hunting for them. |
* enable multiple declarations of forward plugin Signed-off-by: Chris O'Haver <[email protected]>
Signed-off-by: Chris O'Haver [email protected]
1. Why is this pull request needed and what does it do?
This PR enables multiple forward plugin definitions in a server block.
When processing a query, each forward instance is evaluated in their order in the Corefile.
This implementation chains the multiple forward plugin instances to each other via the existing
forward.Next
. This keeps the amount of code change to a minimum.An alternate solution is to create a slice of
Forward
structs, and loop through each one, essentially acting as a single plugin that checks multipleForward
instances.2. Which issues (if any) are related?
This limitation comes up now and then in Q&A.
3. Which documentation changes (if any) need to be made
4. Does this introduce a backward incompatible change or deprecation?
no