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

feat(inputs.powerdns_recursor): Support for new PowerDNS recursor control protocol #9633

Merged
merged 26 commits into from
Dec 12, 2022

Conversation

OrfeasZ
Copy link
Contributor

@OrfeasZ OrfeasZ commented Aug 16, 2021

Required for all PRs:

  • Updated associated README.md.
  • Wrote appropriate unit tests.
  • Pull request title or commits are in conventional commit format (e.g. feat: or fix:)

Since version 4.5.0, the PowerDNS recursor control protocol was updated to include a 32-bit status code before each request and response. This commit adds a new configurable option (new_control_protocol) to the PowerDNS Recursor input plugin that can be enabled to allow telegraf to properly communicate with newer servers. These changes preserve backwards compatibility with existing configurations.

fixes: #12252
fixes: #9494

Since version 4.5.0, the PowerDNS recursor control protocol was updated
to include a 32-bit status code before each request and response. This
commit adds a new configurable option (`new_control_protocol`) that
can be enabled to allow telegraf to properly communicate with newer
servers.
@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Aug 16, 2021
@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Aug 16, 2021

!signed-cla

@ajoergensen
Copy link

Are there any plans to merge the PR into release?

With PowerDNS Recursor v4.6 the error message is different, but I believe it's the same issue

[inputs.powerdns_recursor] Error in plugin: dial unixgram /run/pdns-recursor/pdns_recursor_telegraf2715021145323247347->/run/pdns-recursor/pdns_recursor.controlsocket: connect: protocol wrong type for socket

@powersj
Copy link
Contributor

powersj commented Jan 6, 2022

Are there any plans to merge the PR into release?

I resolved the conflict, however, tests and linters are failing.

Once tests are passing, artifacts will attach to this PR which you can download and use. If you could confirm those artifacts resolve the issues on newer versions of PowerDNS Recusrsor that would be very helpful.

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jan 6, 2022

@powersj I've pushed some fixes for the tests and linters, and everything should pass checks as expected now 🤞. I currently can't test on PDNS 4.6 but if @ajoergensen can once this is built it would be great!

@ajoergensen
Copy link

I still get the same error:

telegraf[83421]: 2022-01-06T15:44:20Z E! [inputs.powerdns_recursor] Error in plugin: dial unixgram /run/pdns-recursor/pdns_recursor_telegraf4605115996352163493->/run/pdns-recursor/pdns_recursor.controlsocket: connect: protocol wrong type for socket

Config looks like this

[[inputs.powerdns_recursor]]
    unix_sockets = [ "/run/pdns-recursor/pdns_recursor.controlsocket" ]
    socket_dir = "/run/pdns-recursor"
    socket_mode = "0666"
    new_control_protocol = true

I will try and debug more tomorrow.

@ajoergensen
Copy link

I have installed the 1.22.0 snapshot on all my PowerDNS Recursor servers; on those running 4.5.x I am now getting data again, so the fix is working as expected.

On my test servers (running 4.6.0) I get the same error as mentioned before:

Jan 07 11:41:20 dnsserver telegraf[13743]: 2022-01-07T10:41:20Z E! [inputs.powerdns_recursor] Error in plugin: dial unixgram /run/pdns-recursor/pdns_recursor_telegraf5411160192932929100->/run/pdns-recursor/pdns_recursor.controlsocket: connect: protocol wrong type for socket

I'm not sure how to debug the issue.

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jan 7, 2022

This probably means that they changed something in the protocol again. We'll be updating our servers to 4.6.0 sometime soon so I'll be debugging this then, but until then I can't offer any tips.

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jan 7, 2022

Actually, looking at the changelog for 4.6.0 I came across this which would explain this issue.

@dmgeurts
Copy link

Has any progress been made on this or can Telegraf not poll PowerDNS (v4.7) via unix_socket?

@vquie
Copy link

vquie commented Apr 29, 2022

Too bad this hasn't made any progress yet.
I switched to the prometheus plugin that queries http://localhost:8082/metrics for the metrics. Though I had to rebuild all dashboards I can now update independently of this plugin.

@powersj
Copy link
Contributor

powersj commented Jul 11, 2022

@OrfeasZ I see that you have rebased on master. Is this ready to go? The last conversation with @ajoergensen made it seem that there was still development to do? Thanks!

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jul 11, 2022

It is not, I just updated my copy. Currently working on adding support for the new protocol.

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jul 11, 2022

This is basically ready but I have only tested it locally. We'll roll it out gradually on our infrastructure and I'll report back / send patches if there's any issues as that happens.

@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Jul 11, 2022

I should note that, in attempting to maintain backwards-compatibility with all versions (including the one this PR was originally targetting), the original description is no longer valid. The newly introduced variable is now control_protocol_version, with accepted values as seen below:

PowerDNS Version Protocol Version
<4.5.0 1 (default)
4.5.0 - 4.5.9 2
>=4.6.0 3

These versions are arbitrary since this protocol is internal and the powerdns devs don't version it.

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

@OrfeasZ huge thank you for doing this PR.

I have thrown in some suggestions that would be nice to see you take a look at. If you don't have time, let us know and I can see about taking this PR over.

Thanks!

plugins/inputs/powerdns_recursor/README.md Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/README.md Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/protocol_commons.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/protocol_commons.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/powerdns_recursor_test.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/powerdns_recursor_test.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/powerdns_recursor_test.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/powerdns_recursor_test.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/powerdns_recursor_test.go Outdated Show resolved Hide resolved
@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Nov 17, 2022

@powersj this is good to go from my side 👍

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Nov 17, 2022
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks for the update @OrfeasZ! Two small requests in the code and one suggestion, then we are good to go I think.

plugins/inputs/powerdns_recursor/protocol_commons.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/protocol_commons.go Outdated Show resolved Hide resolved
plugins/inputs/powerdns_recursor/sample.conf Outdated Show resolved Hide resolved
Should prevent panics in the case PowerDNS updates their implementation and returns data not conforming to what we expect.
@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Nov 25, 2022

@srebhan Made the changes you requested. Let me know what you think about the endianness thing above!

@OrfeasZ OrfeasZ requested a review from srebhan November 25, 2022 19:54
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Besides the host endianness issue the code looks good. I will discuss with @powersj on how we should proceed on that. Thanks for your contribution @OrfeasZ!

@powersj powersj requested a review from srebhan December 12, 2022 15:28
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@OrfeasZ nice update. Can you please make the one if-else block a switch so we can land this today!?

plugins/inputs/powerdns_recursor/protocol_commons.go Outdated Show resolved Hide resolved
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@OrfeasZ
Copy link
Contributor Author

OrfeasZ commented Dec 12, 2022

@srebhan done

@telegraf-tiger
Copy link
Contributor

@srebhan srebhan merged commit 459a658 into influxdata:master Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
9 participants