-
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
fix(inputs.execd): read from stdout using ReadLine instead of scanner.Scan to overcome 64kb buffer limit #12935
Conversation
When reading the process' output stream, scanner.Scan() can fail to process lines longer than the default scan buffer (64Kb). In that case, execd logs the error and stops reading stdout, even if the process is still running. - Added a parameter for buffer size (in Kb), with default 64Kb - Changed the code to continue scanning stdout even when the scan errors out
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.
Thank for the PR to go along with the issue! Couple requests in line, let me know if you think that is possible.
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.
Thanks!
FYI I pushed one change to fix the linter so I could approve
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.
Just one small comment @spaghettidba.
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
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.
Thanks @spaghettidba for this nice fix!
@@ -50,6 +50,10 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details. | |||
## Delay before the process is restarted after an unexpected termination | |||
restart_delay = "10s" | |||
|
|||
## Buffer size used to read from the command output stream | |||
## Optional parameter. Default is 64 Kib, minimum is 16 bytes | |||
# buffer_size = "64Kib" |
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.
2023-06-20T10:40:29Z I! Loading config: /etc/telegraf/telegraf.conf
2023-06-20T10:40:29Z E! error loading config file /etc/telegraf/telegraf.conf: error parsing execd, line 218: (execd.Execd.BufferSize) units: unknown unit Kib in 128Kib
Getting these errors with Kib
. Shouldn’t the unit say KiB
?
Resolves #12934