-
Notifications
You must be signed in to change notification settings - Fork 485
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
feat(data): Make MaxEventSize a service configuration setting #3891
Conversation
@jinlinGuan , please remember to complete the PR template when you take this PR out of draft. |
Let's hold this PR and discuss the design here #3237 (comment) |
fd81e8e
to
5ef208f
Compare
62e691f
to
12daf8a
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.
LGTM
8099421
to
dc6b798
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.
LGTM
dataBytes, readErr := io.ReadAll(r.Body) | ||
if readErr != nil { | ||
err = errors.NewCommonEdgeX(errors.KindIOError, "AddEventRequest I/O reading failed", nil) | ||
} else { | ||
err = utils.CheckPayloadSize(dataBytes, config.MaxEventSize*1000) | ||
} |
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.
Should check r.ContentLength > config.MaxEventSize*1000
before attempting to read the body, otherwise this new settings doesn't really help since we are reading it no matter what.
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.
r.ContentLength is a better option, but why do we limit the check for CBOR only?
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.
@lenny-intel Although the request usually contains ContentLength, it's not a required field.
Should we depend on it? It might be unknown.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
// ContentLength records the length of the associated content.
// The value -1 indicates that the length is unknown.
// Values >= 0 indicate that the given number of bytes may
// be read from Body.
//
// For client requests, a value of 0 with a non-nil Body is
// also treated as unknown.
ContentLength int64
I suggest to check ContentLength first, and keep the utils.CheckPayloadSize(dataBytes, config.MaxEventSize*1000)
step after ReadAll
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.
Yes, check first, if -1 use utils.CheckPayloadSize
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.
Looks good once address @cloudxxx8 comment on ContentLength
25000KB (25MB) by default close edgexfoundry#3237 Signed-off-by: Ginny Guan <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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
close #3237
25000KB (25MB) by default
Signed-off-by: Ginny Guan [email protected]
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)Testing Instructions
Build and run Core Data locally with rest of EdgeX non-secure services running in Docker, and
POST an event
e.g.
For message bus,
e.g.
curl -ki http://localhost:59900/api/v2/device/name/Random-Binary-Device/Binary\?ds-pushevent\=yes
New Dependency Instructions (If applicable)