Added support for write-timeout support to fluentd plugin.#35716
Added support for write-timeout support to fluentd plugin.#35716imumesh18 wants to merge 3 commits intomoby:masterfrom imumesh18:write-timeout-config
Conversation
Signed-off-by: dungeonmaster18 <[email protected]>
Signed-off-by: dungeonmaster18 <[email protected]>
|
Hey @thaJeztah and @cpuguy83 . I have added support for write timeout. Please review it whenever you have time. Also I have replaced the commit id with version tag in vendor.conf for all the libraries used by fluentd plugin. P.S Once you guys think this is good just ping me I will start the work on docs and auto complete command for bash and zsh. Also I will squash the commits. Thanks |
| wtd, err := time.ParseDuration(info.Config[writeTimeoutKey]) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
Should we check for negative durations and produce an error?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
We should also check for extremely long timeout values to prevent daemon waiting on the write.
There was a problem hiding this comment.
So @anusha-ragunathan how long do you thing it should wait. I was thinking of something in minutes.
There was a problem hiding this comment.
@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 🙈
There was a problem hiding this comment.
@dungeonmaster18 I think logger has ring buffer for this case. @cpuguy83
There was a problem hiding this comment.
As far I know ring buffer is nothing but the circular buffer with fixed size. Correct me if I am wrong @ripcurld0
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
|
ping @anusha-ragunathan PTAL |
daemon/logger/fluentd/fluentd.go
Outdated
| defaultMaxRetries = math.MaxInt32 | ||
|
|
||
| // Write() will not time out | ||
| defaultWriteTimeout = time.Duration(0) |
There was a problem hiding this comment.
We should still set a default timeout. The main thing we don't want to happen is to allow a dead logging backend lock up the daemon in some way.
There was a problem hiding this comment.
I'd do something much higher, we don't want to drop logs.
30s timeout should be fine.
There was a problem hiding this comment.
sounds good to me.
|
PTAL @thaJeztah @anusha-ragunathan @cpuguy83. P.S should I address more 5xx errors. Right now I am only checking for 501 502 503. Would like to know your views on this? |
daemon/logger/fluentd/fluentd.go
Outdated
There was a problem hiding this comment.
I'm not sure I understand this error handling. time.ParseDuration shouldn't be making an HTTP request.
There was a problem hiding this comment.
yup it's wrong I realized later 🙈 .
There was a problem hiding this comment.
I am bit confused with the http status code. Where should I be checking it.
There was a problem hiding this comment.
Probably https://github.com/moby/moby/pull/35716/files#diff-4e76640044eca60a4a45cd8631049282R108 needs a properly typed error (of type InvalidParameter)
There was a problem hiding this comment.
How about InvalidParameter: write-timeout must be a positive integer @cpuguy83
There was a problem hiding this comment.
It's not the error message that matters so much as the error type, which needs to implement this interface: https://github.com/moby/moby/blob/master/api/errdefs/defs.go#L9
There was a problem hiding this comment.
btw, this can just use errdefs.InvalidParameter(errors.New("some error")) now.
Signed-off-by: dungeonmaster18 <[email protected]>
| writeTimeout := defaultWriteTimeout | ||
| i, _ := strconv.Atoi(info.Config[writeTimeoutKey]) | ||
| if info.Config[writeTimeoutKey] != "" && i >= 0 { | ||
| wtd, err := time.ParseDuration(info.Config[writeTimeoutKey]) |
There was a problem hiding this comment.
You can directly assign to writeTimeout
|
ping @dungeonmaster18 could you have a look at the review comments? Looks like the change to use the |
|
@imumesh18 CI build fails to: And there is reviews above which needs to be addressed |
|
Looks like this PR is stall for quite some time now. Would you mind if I resubmit it with review comments fixed? We actually got hit by a bug fixed here: as mentioned by cpuguy83 in this comment, having no default timeout value leads to daemon lock up whenever fluentd times out, thus producing the same symptoms as described in #38092 ( |
Signed-off-by: dungeonmaster18 [email protected]
- What I did
- A picture of a cute animal (not mandatory but encouraged)
