-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Read backends data even if buffered to temp file #2408
Read backends data even if buffered to temp file #2408
Conversation
/approve |
local body = ngx.req.get_body_data() | ||
|
||
if not body then | ||
-- request body might've been wrote to tmp file if body > client_body_buffer_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.
s/wrote/written
@@ -39,6 +39,8 @@ import ( | |||
var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { | |||
f := framework.NewDefaultFramework("dynamic-configuration") | |||
|
|||
var defaultNginxConfigMapData map[string]string = nil |
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.
where is this being used?
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.
Nice catch, issa relic of a previous iteration. Will nip
@@ -104,6 +112,30 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { | |||
Expect(restOfLogs).ToNot(ContainSubstring("first sync of Nginx configuration")) | |||
}) | |||
|
|||
It("configuration module should read from temp file when request body > client_body_buffer_size", func() { | |||
// Update client-body-buffer-size to 1 byte | |||
err := f.UpdateNginxConfigMapData("client-body-buffer-size", "8") |
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.
lower than 8 is not 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.
Didn't really make a difference, I could lower it though.
My hypothesis for why it doesn't matter comes from reading about how nginx applies the client body buffer size limit. Seems like there is sometimes Nginx pre-reads responses, and if Nginx is able to pre-read the entire response in the pre-read buffer - the client body buffer size is not looked at at all.
It also seems to compare only what is left of the response after pre-reading against the client body buffer size instead of the size of the entire response: https://github.com/nginx/nginx/blob/55b37eff8f700ea1dd279368d5a4a7b00f3c1344/src/http/ngx_http_request_body.c#L165
But yes, can lower it to 1/2 for clarity. Seems like we would still need the same amount of replicas though to reliably reproduce temp file buffering.
@@ -104,6 +112,30 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() { | |||
Expect(restOfLogs).ToNot(ContainSubstring("first sync of Nginx configuration")) | |||
}) | |||
|
|||
It("configuration module should read from temp file when request body > client_body_buffer_size", func() { |
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 test should not care about which module is doing what, rather it should make sure that given a payload of backends that can not be buffered then the request to that backends should still succeed
please also run |
39b8986
to
6ac63e0
Compare
/lgtm |
Actually read from the file Logs probably shouldn't assume knowledge of implementation detail Typos Added integration test, and dynamic update config refactor Don't force the 8k default Minimal test case to make the configuration/backends request body write to temp file Leverage new safe config updating methods, and use 2 replicas instead of 4 Small refactor Better integration test, addresses other feedback Update bindata
6ac63e0
to
d3d383d
Compare
@ElvinEfendi added updated bindata, might need you to re-approve. Refactored the integration test to make more sense. |
Codecov Report
@@ Coverage Diff @@
## master #2408 +/- ##
==========================================
- Coverage 41.05% 40.91% -0.14%
==========================================
Files 74 74
Lines 5252 5252
==========================================
- Hits 2156 2149 -7
- Misses 2803 2809 +6
- Partials 293 294 +1
Continue to review full report at Codecov.
|
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, andrewlouis93, ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
Which issue this PR fixes
Special notes for your reviewer:
cc r/ @ElvinEfendi @zrdaley