-
Notifications
You must be signed in to change notification settings - Fork 543
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
Add messageSizeLargerErrFmt error to errors catalog #2470
Conversation
A few questions:
|
dfc509e
to
b4cb39e
Compare
I think a bit of copy/paste or removing the flag name from the error message is a better choice that moving a distributor specific flag outside the distributor package.
I've noticed this too 😭. Most of the things we use
I think having two different methods for the different types of limits would be a better choice than a |
Thanks! Switched to copy/paste and 2 different methods |
pkg/util/http.go
Outdated
@@ -172,14 +173,18 @@ func ParseProtoReader(ctx context.Context, reader io.Reader, expectedSize, maxSi | |||
return body, nil | |||
} | |||
|
|||
func NewMsgSizeTooLargeErr(actual, limit int) error { | |||
return errors.New(globalerror.MsgSizeTooLarge.MessageWithGlobalLimitConfig(fmt.Sprintf("the incoming push request has been rejected because its message size of %d bytes is larger than the allowed limit of %d bytes", actual, limit), "distributor.max-recv-msg-size")) |
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.
This looks like a generic function used to generate the error, but then it contains "distributor.max-recv-msg-size" which is very specific. This error is returned from the exported function ParseProtoReader()
which is not just called by the remote write.
I would suggest a different approach:
- From this package, return a globally defined static error, like
var ErrMessageTooLarge = errors.New("the request has been rejected because its message size exceed the limit")
. The message is intentionally generic and static - In
pkg/util/push/
check the error returned byParseProtoReader
and if it's aErrMessageTooLarge
then remap it into a more specific error (mentioning the distributor flag in this case, which is correct)
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.
- I replaced it with a struct because the existing error messages are already dynamic with the actual and limit numbers included in the msg, is that okay?
c9a3351
to
4e454f5
Compare
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.
Good job! The new logic looks good to me. Just a few final comments, and then we should be good go!
4e454f5
to
4798f5b
Compare
Co-authored-by: Marco Pracucci <marco@pracucci.com>
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.
LGTM, thanks!
What this PR does
Add messageSizeLargerErrFmt error to errors catalog.
Which issue(s) this PR fixes or relates to
Fixes #2432
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]