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

dnsdist: add pooling support for RemoteLoggerInterface #15123

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

esensar
Copy link
Contributor

@esensar esensar commented Feb 5, 2025

Short description

This adds a new kind of RemoteLoggerInterface: RemoteLoggerPool. It can take multiple other RemoteLoggerInterfaces and pass data to them in round-robin order by default.

This also adds additional option to newRemoteLogger, newFrameStreamTcpLogger and newFrameStreamUnixLogger: connectionCount, which can be used to generate a pool with multiple connections.

Closes: #14861

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@esensar
Copy link
Contributor Author

esensar commented Feb 5, 2025

There is a lot of noise in pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc due to formatting. Let me know if that needs to be fixed or if I should add formatting in a separate PR.

@miodvallat
Copy link
Contributor

Can you split this work in two commits, one with most of the formatting/whitespace changes and another with the actual work? This would indeed help reviewing.

esensar and others added 4 commits February 5, 2025 15:58
This adds a new kind of `RemoteLoggerInterface`: `RemoteLoggerPool`.
It can take multiple other `RemoteLoggerInterface`s and pass data to
them in round-robin order by default.

This also adds additional option to `newRemoteLogger`, `newFrameStreamTcpLogger`
and `newFrameStreamUnixLogger`: `connectionCount`, which can be used to
generate a pool with multiple connections.

Closes: PowerDNS#14861
@esensar esensar force-pushed the feature/dnstap-multi-stream branch from 01d1012 to 95fb88b Compare February 5, 2025 14:59
@coveralls
Copy link

coveralls commented Feb 5, 2025

Pull Request Test Coverage Report for Build 13174750599

Details

  • 77 of 191 (40.31%) changed or added relevant lines in 4 files are covered.
  • 212 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.05%) to 64.671%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/remote_logger_pool.hh 0 13 0.0%
pdns/remote_logger_pool.cc 0 22 0.0%
pdns/dnsdistdist/dnsdist-configuration-yaml.cc 5 34 14.71%
pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc 72 122 59.02%
Files with Coverage Reduction New Missed Lines %
pdns/recursordist/negcache.hh 2 88.24%
modules/gsqlite3backend/gsqlite3backend.cc 2 94.44%
pdns/backends/gsql/gsqlbackend.cc 2 82.2%
ext/json11/json11.cpp 2 62.72%
pdns/recursordist/test-syncres_cc2.cc 3 88.91%
pdns/misc.hh 3 87.62%
pdns/packethandler.cc 3 72.49%
pdns/axfr-retriever.cc 3 67.34%
pdns/recursordist/lwres.cc 3 69.23%
pdns/iputils.hh 3 77.94%
Totals Coverage Status
Change from base Build 13160155488: -0.05%
Covered Lines: 128299
Relevant Lines: 167314

💛 - Coveralls

@miodvallat
Copy link
Contributor

Can't comment about the usefulness, but the code reads ok.

Can you update the meson rules so that the CI gets a chance to pass?

@esensar
Copy link
Contributor Author

esensar commented Feb 5, 2025

Can't comment about the usefulness, but the code reads ok.

Can you update the meson rules so that the CI gets a chance to pass?

Thank you. I went for a very simple approach for now. There was a discussion of different strategies (for picking the interface(s) to pass data to), but I think these are easy to add onto this, since it really just forwards data to one of the interfaces.

This also fixes a bug with loggers in YAML, which had hardcoded
connection status. For `RemoteLogger` that worked by having it always
connect, but for `FrameStreamLogger` it never connected. Now the
behavior is the same as lua, by checking the client mode flag.
There was not option of having no alter function defined, even though it
is expected by config. If it wasn't defined, it passed an invalid alter
function into the action. This makes the alter function optional and
properly checks if it was found in configuration.
@miodvallat
Copy link
Contributor

One concern, though, is that RemoteLoggerPool::queueData() is not thread-safe. Are you sure that there is no risk of multiple threads attempting to invoke it? If so, you need to protect the d_pool_it value changes with some serialization object.

@esensar
Copy link
Contributor Author

esensar commented Feb 6, 2025

One concern, though, is that RemoteLoggerPool::queueData() is not thread-safe. Are you sure that there is no risk of multiple threads attempting to invoke it? If so, you need to protect the d_pool_it value changes with some serialization object.

You are right. I have overlooked that. I can see that RemoteLogger has a lock in queueData, so I guess there is that risk, so something similar needs to be done here.

@esensar
Copy link
Contributor Author

esensar commented Feb 6, 2025

Also, I was wondering if I should change the implementation of toString() for this class. Right now it could produce a very long string, because it is showing information of all the underlying loggers.

The alternative would be to just show number of loggers and stats, but then that would hide the addresses. This also brings me to the name and address implementation. I am not sure what their exact purpose is, so I was not sure how to implement them for this, since it is not guaranteed that all loggers will be the same (it is right now, because the only usage is in generating multiple instances of the same logger, but in general case, it is not).

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.

dnsdist: add multi-stream dnstap sockets
3 participants