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

inputs.statsd: Error in plugin: read udp [::]:8125: use of closed network connection #9867

Closed
passing opened this issue Oct 6, 2021 · 4 comments · Fixed by #11043
Closed
Labels
area/statsd bug unexpected problem or unintended behavior

Comments

@passing
Copy link

passing commented Oct 6, 2021

Relevant telegraf.conf:

[[inputs.statsd]]

Steps to reproduce:

having placed logstash.conf in your working directory, execute:

docker run -ti -v $(pwd)/telegraf.conf:/etc/telegraf/telegraf.conf telegraf:1.18.3 --test

the run succeeds with the following output:

2021-10-06T13:27:24Z I! Starting Telegraf 1.18.3
2021-10-06T13:27:24Z I! Using config file: /etc/telegraf/telegraf.conf
2021-10-06T13:27:24Z I! [inputs.statsd] UDP listening on "[::]:8125"
2021-10-06T13:27:24Z I! [inputs.statsd] Started the statsd service on ":8125"
2021-10-06T13:27:24Z I! [inputs.statsd] Stopping the statsd service
2021-10-06T13:27:24Z I! [inputs.statsd] Stopped listener service on ":8125"

using any later version, doesn't:

docker run -ti -v $(pwd)/telegraf.conf:/etc/telegraf/telegraf.conf telegraf:1.19.3 --test
docker run -ti -v $(pwd)/telegraf.conf:/etc/telegraf/telegraf.conf telegraf:1.20.0 --test

the run fails with the following output:

2021-10-06T13:25:24Z I! Starting Telegraf 1.19.3
2021-10-06T13:25:24Z I! Using config file: /etc/telegraf/telegraf.conf
2021-10-06T13:25:24Z I! [inputs.statsd] UDP listening on "[::]:8125"
2021-10-06T13:25:24Z I! [inputs.statsd] Started the statsd service on ":8125"
2021-10-06T13:25:24Z I! [inputs.statsd] Stopping the statsd service
2021-10-06T13:25:24Z E! [inputs.statsd] Error in plugin: read udp [::]:8125: use of closed network connection
2021-10-06T13:25:24Z I! [inputs.statsd] Stopped listener service on ":8125"
2021-10-06T13:25:24Z E! [telegraf] Error running agent: input plugins recorded 1 errors

Expected behavior:

test run should exit successfully without any error

Actual behavior:

test run fails with error

@passing passing added the bug unexpected problem or unintended behavior label Oct 6, 2021
@powersj
Copy link
Contributor

powersj commented Apr 26, 2022

Hi @passing,

Trying to run the statsd input in --test mode is not very useful. Are you only seeing this when using --test mode?

Thanks!

@powersj powersj added the waiting for response waiting for response from contributor label Apr 26, 2022
@passing
Copy link
Author

passing commented Apr 26, 2022

Hi @powersj,

We only see this in --test mode which we use for automated tests for our telegraf deployment configuration: whenever changes are made in a repository, a build runs to verify that the configuration is valid. The --test mode seems to be the best way to do that, but due to the issue we cannot use it in any project that uses the inputs.statsd plugin.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Apr 26, 2022
powersj added a commit to powersj/telegraf that referenced this issue Apr 27, 2022
Errors from the UDPListen function were previously not checked. In a
recent minor release we started checking them, which introduced more
visible errors to users. However, when statsd is run with the `--test`
option or when a user kills Telegraf with a ctrl-c, an error now shows
up as the read is still trying, after a close has occured.

The ReadFromUDP call blocks untill something is received, so I don't
believe there is anything else for us to check to prevent.

Fixes: influxdata#9867
@powersj
Copy link
Contributor

powersj commented Apr 27, 2022

whenever changes are made in a repository, a build runs to verify that the configuration is valid. The --test mode seems to be the best way to do that

Interesting, --test will essentially let you know if your inputs work and your TOML configs are parsable, but be aware it does not run outputs.

The reason for the error message is from this change where Telegraf started checking some additional errors.

Given we previously weren't checking for a closed network connection error in the first place, I think it is safe to make a small update where we return nil. I've put up PR #11043 with a possible workaround. Give it a shot!

@passing
Copy link
Author

passing commented Apr 28, 2022

Thank you!
I just gave it a try using the PR build artifacts to patch our docker image:

ADD https://output.circle-artifacts.com/output/job/49cf6b94-b663-4f62-8a7a-34cd4cc32f3d/artifacts/0/build/dist/telegraf-1.23.0~b51bc936_linux_amd64.tar.gz /tmp/telegraf.tar.gz
RUN tar xzv -C /usr/bin -f /tmp/telegraf.tar.gz ./telegraf-1.23.0/usr/bin/telegraf --strip-components=4

with that, the automated test is working again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/statsd bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants