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

plugin/dnstap: various cleanups #4179

Merged
merged 9 commits into from
Oct 12, 2020
Merged

plugin/dnstap: various cleanups #4179

merged 9 commits into from
Oct 12, 2020

Conversation

miekg
Copy link
Member

@miekg miekg commented Oct 5, 2020

Remove identical functions ToClientQuery etc, and just use ToTapMessage
with the type. Remove the Builder type and just make it Msg and make
error handling explicit instead of using a Err field that gets checked
only at the end.

A recent issue made me look into this plugin, I suspect various other
cleanups (hopefully deletion of code) can be made as well

@miekg
Copy link
Member Author

miekg commented Oct 5, 2020

ok, this needs more work, msg/msg.go just wraps the tap struct which seems to add an indirection that creates confusion. I'm going to see where this ends and how big of a code reduction I can create (if any)

plugin/dnstap/msg/msg.go Outdated Show resolved Hide resolved
plugin/dnstap/msg/msg.go Outdated Show resolved Hide resolved
@miekg miekg force-pushed the dnstap2 branch 2 times, most recently from bcbb283 to 6add490 Compare October 5, 2020 17:56
@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2020

Codecov Report

Merging #4179 into master will increase coverage by 0.15%.
The diff coverage is 32.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4179      +/-   ##
==========================================
+ Coverage   55.96%   56.11%   +0.15%     
==========================================
  Files         225      224       -1     
  Lines        9938     9856      -82     
==========================================
- Hits         5562     5531      -31     
+ Misses       3910     3866      -44     
+ Partials      466      459       -7     
Impacted Files Coverage Δ
plugin/dnstap/context.go 80.00% <ø> (ø)
plugin/forward/dnstap.go 8.10% <0.00%> (-59.64%) ⬇️
plugin/dnstap/writer.go 46.15% <46.15%> (ø)
plugin/dnstap/setup.go 36.36% <50.00%> (+3.03%) ⬆️
plugin/dnstap/handler.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2ec292...6add490. Read the comment docs.

Copy link
Contributor

@rdrozhdzh rdrozhdzh left a comment

Choose a reason for hiding this comment

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

I like your idea to simplify this plugin. However, your changes make new version of the plugin incompatible with old version. There were a lot of public properties and methods in dnstap package. I think we should not simply remove them without deprecation for some reasonable period of time.

plugin/dnstap/context.go Outdated Show resolved Hide resolved
plugin/dnstap/handler.go Show resolved Hide resolved
plugin/dnstap/msg/msg.go Show resolved Hide resolved
plugin/dnstap/msg/msg.go Show resolved Hide resolved
plugin/dnstap/writer.go Outdated Show resolved Hide resolved
plugin/dnstap/writer.go Outdated Show resolved Hide resolved
@rdrozhdzh
Copy link
Contributor

@miekg , I think we can just fix the issue #4165 now and rework dnstap plugin later. What do you think?

@miekg
Copy link
Member Author

miekg commented Oct 8, 2020 via email

@rdrozhdzh
Copy link
Contributor

So, are you going to merge your version? And release it in 1.8.0?
Please, add notes about backward incompatibility then. And I will close my PR, if so.

@miekg
Copy link
Member Author

miekg commented Oct 8, 2020 via email

@codecov-io
Copy link

codecov-io commented Oct 9, 2020

Codecov Report

Merging #4179 into master will increase coverage by 0.10%.
The diff coverage is 43.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4179      +/-   ##
==========================================
+ Coverage   55.96%   56.07%   +0.10%     
==========================================
  Files         225      223       -2     
  Lines        9938     9839      -99     
==========================================
- Hits         5562     5517      -45     
+ Misses       3910     3863      -47     
+ Partials      466      459       -7     
Impacted Files Coverage Δ
plugin/forward/dnstap.go 0.00% <0.00%> (-67.75%) ⬇️
plugin/forward/setup.go 61.22% <0.00%> (-1.72%) ⬇️
plugin/forward/forward.go 45.78% <25.00%> (-1.78%) ⬇️
plugin/dnstap/setup.go 36.36% <33.33%> (+3.03%) ⬆️
plugin/dnstap/writer.go 61.90% <61.90%> (ø)
plugin/dnstap/dnstapio/io.go 67.24% <65.51%> (ø)
plugin/dnstap/handler.go 100.00% <100.00%> (ø)
core/dnsserver/server.go 12.21% <0.00%> (-0.29%) ⬇️
core/dnsserver/server_https.go 0.00% <0.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2ec292...8d3f901. Read the comment docs.

@miekg
Copy link
Member Author

miekg commented Oct 9, 2020

comments addressed. PTAL

@miekg miekg mentioned this pull request Oct 9, 2020
A recent issue made me look into this plugin, I suspect various other
cleanups (hopefully deletion of code) can be made as well

Remove identical functions ToClientQuery etc, and just use tap.Message
as the base type in plugin. Keep msg/ for a few helper functions that
may proof useful.

This remove the whole test directory as we will just check the things we
are interested in which gives much better feedback and keeps that code
closer together.

tapwr dir is also not needed, writer_test.go was just duplicating the
tests already done. This moves writer.go to the top directory.

Make the only user of dnstap, the forward plugin, use the newer code
also remove the test, a better test there would be a full e2e test to
see the correct thing happens.

Cleanup the Tapper interface and move it to dnstapio where it belongs,
remove higher level interfaces that are not used. This remove
dnstap.Tapper and dnstap.IORoutines.

Use the standard mechanism for getting access to a plugin and remove
shuffling the plugin into the context.

Signed-off-by: Miek Gieben <miek@miek.nl>
Copy link
Contributor

@rdrozhdzh rdrozhdzh left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. The config options for message types are highly desired

plugin/dnstap/handler.go Show resolved Hide resolved
plugin/dnstap/writer.go Outdated Show resolved Hide resolved
plugin/forward/dnstap.go Show resolved Hide resolved
@miekg
Copy link
Member Author

miekg commented Oct 9, 2020 via email

Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
…ere these fields have been preparsed

Signed-off-by: Miek Gieben <miek@miek.nl>
all these fields have been preparsed, no need for dnstap to be pedantic
and check (and save!) this error again.

Simplifies it a bit more.

Signed-off-by: Miek Gieben <miek@miek.nl>
plugin/forward/dnstap.go Outdated Show resolved Hide resolved
plugin/forward/dnstap.go Outdated Show resolved Hide resolved
plugin/forward/dnstap.go Outdated Show resolved Hide resolved
miekg and others added 4 commits October 12, 2020 15:17
Co-authored-by: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Copy link
Contributor

@rdrozhdzh rdrozhdzh left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@miekg
Copy link
Member Author

miekg commented Oct 12, 2020

thanks for the thorough review @rdrozhdzh

@miekg miekg merged commit b3b8a7e into master Oct 12, 2020
@miekg miekg deleted the dnstap2 branch October 12, 2020 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants