-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Apply ping deadline to dns lookup #7140
Apply ping deadline to dns lookup #7140
Conversation
e92a538
to
e734785
Compare
Had trouble coming up with a good way to test the timeout but open to suggestions |
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.
On testing, if we use the Resolver (see comment) through an interface then it should be possible to inject a mock implementation in the test.
plugins/inputs/ping/ping.go
Outdated
error := make(chan error) | ||
|
||
go func() { | ||
addrs, err := net.ResolveIPAddr(network, destination) |
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.
If we create a Resolver we can use the functions that take a Context, this would be my preferred method to timeout the lookup since it won't leave a goroutine orphaned and should be simpler.
e6af512
to
a9288bd
Compare
a9288bd
to
4b17151
Compare
Modified to use |
@danielnelson Is this what you had in mind? |
This includes dns lookup in ping deadline. The deadline context is used for performing dns lookups, thus a ping collection will fail if the dealine times out during a lookup
Fixes #5059
Required for all PRs: