-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Added support for write-timeout support to fluentd plugin. #35716
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,11 @@ const ( | |
| defaultRetryWait = 1000 | ||
| defaultMaxRetries = math.MaxInt32 | ||
|
|
||
| // Write() will time out after 20s | ||
| defaultWriteTimeout = time.Duration(20 * time.Second) | ||
|
|
||
| addressKey = "fluentd-address" | ||
| writeTimeoutKey = "fluentd-write-timeout" | ||
| bufferLimitKey = "fluentd-buffer-limit" | ||
| retryWaitKey = "fluentd-retry-wait" | ||
| maxRetriesKey = "fluentd-max-retries" | ||
|
|
@@ -84,6 +88,18 @@ func New(info logger.Info) (logger.Logger, error) { | |
| return nil, err | ||
| } | ||
|
|
||
| writeTimeout := defaultWriteTimeout | ||
| i, _ := strconv.Atoi(info.Config[writeTimeoutKey]) | ||
| if info.Config[writeTimeoutKey] != "" && i >= 0 { | ||
| wtd, err := time.ParseDuration(info.Config[writeTimeoutKey]) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check for negative durations and produce an error?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we need to check what status-code is returned by the API in case of an invalid value (haven't checked yet) (make sure it doesn't return a 5xx error)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also check for extremely long timeout values to prevent daemon waiting on the write.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So @anusha-ragunathan how long do you thing it should wait. I was thinking of something in minutes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thaJeztah Actually I am completely new to these things so I am kind of learning how can I handle server error(5xx). It will take time but I will push the changes by next week. Actually I am bit busy with my college exams 🙈
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dungeonmaster18 I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far I know ring buffer is nothing but the circular buffer with fixed size. Correct me if I am wrong @ripcurld0
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dungeonmaster18 : regarding setting an upper limit on the timeout, lets skip that. Users should be aware of what they are setting for the timeout value. It's hard to predict a good max value. Also, I checked other timeouts. Other than disallowing negative values, there's no other check.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the status-code; The API uses this code https://github.com/moby/moby/blob/master/api/server/httputils/errors.go#L33-L73 (and code from the errdefs package: https://github.com/moby/moby/tree/master/api/errdefs) to convert errors from the daemon into the correct HTTP status codes. You can try creating an API request with an incorrect value for the timeout, and check what status code is returned. |
||
| writeTimeout = wtd | ||
| } else if i < 0 { | ||
| return nil, fmt.Errorf("Invalid Parameter: write-timeout must be a positive integer") | ||
| } | ||
|
|
||
| bufferLimit := defaultBufferLimit | ||
| if info.Config[bufferLimitKey] != "" { | ||
| bl64, err := units.RAMInBytes(info.Config[bufferLimitKey]) | ||
|
|
@@ -130,6 +146,7 @@ func New(info logger.Info) (logger.Logger, error) { | |
| FluentHost: loc.host, | ||
| FluentNetwork: loc.protocol, | ||
| FluentSocketPath: loc.path, | ||
| WriteTimeout: writeTimeout, | ||
| BufferLimit: bufferLimit, | ||
| RetryWait: retryWait, | ||
| MaxRetry: maxRetries, | ||
|
|
@@ -189,6 +206,7 @@ func ValidateLogOpt(cfg map[string]string) error { | |
| case "tag": | ||
| case addressKey: | ||
| case bufferLimitKey: | ||
| case writeTimeoutKey: | ||
| case retryWaitKey: | ||
| case maxRetriesKey: | ||
| case asyncConnectKey: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
You can directly assign to
writeTimeout