POST/PUT requests with body data got 404 responses during VHDS route discovery#40883
POST/PUT requests with body data got 404 responses during VHDS route discovery#40883barroca wants to merge 20 commits intoenvoyproxy:mainfrom
Conversation
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for trying to address this.
Can you leave some comments on the PR pointing to where redirecting with bodies was addressed?
Also, please add integration tests that validate that using an on-demand VHDS filter works well with a redirect of a request with body.
Thanks!
/wait
ab6b0d1 to
1bd23b7
Compare
|
Thanks for the pointers. AFAICT this was fixed in #15634. |
cpakulski
left a comment
There was a problem hiding this comment.
I think that this PR does not address the core of the problem (correct me if I am wrong!) because it relies on presence of a host which will send a redirect response with code 302. I think that the redirect should be "internal", generated by a code logic inside of a filter. Ideally, after discovering that VH must be resolved via VHDS and body is present, filterchain operations are stopped and resumed after virtual host update has been received. In the meantime, additional chunks of a body may arrive from a client and they should be buffered and sent via filterchain after the virtual host has been resolved and routing decision made. Maybe some signalling is required here to avoid race condition.
| return; | ||
| if (route_exists) { | ||
| // If we have body data, we cannot recreate the stream as it would lose the buffered body. | ||
| // Instead, we continue processing with the current stream which has the body already buffered. |
There was a problem hiding this comment.
If both continueDecoding() and recreateStream end up working properly, what is the incentive to use different paths here?
|
|
||
| // Integration test specifically for the GitHub issue #17891 fix: | ||
| // Verify that VHDS requests with body don't result in 404 responses | ||
| TEST_P(OnDemandIntegrationTest, VhdsWithRequestBodyShouldNotReturn404) { |
There was a problem hiding this comment.
Consider renaming to give better meaning:
s/VhdsWithRequestBodyShouldNotReturn404/VhdsWithRequestBodySuccess/
| } | ||
|
|
||
| // Integration test for requests without body (should still work) | ||
| TEST_P(OnDemandIntegrationTest, VhdsWithoutBodyStillWorksCorrectly) { |
There was a problem hiding this comment.
What's the difference compared to the previous OnDemandVhdsIntegrationTest tests?
Also consider renaming this to something that will make sense to someone reading this code in a year from now, e.g., s/VhdsWithoutBodyStillWorksCorrectly/VhdsWithoutBodySuccess/
(sorry, I don't fully understand what the intent of this test, so there's probably a better name that can be used here)
a0873ba to
e5edf87
Compare
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
…evel filter configuration will not take effect for requests that trigerred on demand processing. Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
…lter.rst Co-authored-by: phlax <phlax@users.noreply.github.com> Signed-off-by: Leonardo da Mata <barroca@gmail.com> Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
0769d7f to
8db29cd
Compare
Signed-off-by: Leonardo da Mata <ldamata@spotify.com>
|
Thanks for the contribution. Here are some my thoughts:
|
|
/wait |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
|
This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Problem Fixed
Files Changed
source/extensions/filters/http/on_demand/on_demand_update.hbool has_body_data_{false};member variablesource/extensions/filters/http/on_demand/on_demand_update.ccdecodeData()method:has_body_data_ = truewhen body data is buffered during VHDS discoveryonRouteConfigUpdateCompletion()method:has_body_data_before callingrecreateStream()continueDecoding()for requests with body datarecreateStream()for requests without body dataonClusterDiscoveryCompletion()method:clearRouteCache()andcontinueDecoding()for body requestsrecreateStream()for non-body requeststest/extensions/filters/http/on_demand/on_demand_filter_test.ccResult
continueDecoding()→ Body preserved → SuccessrecreateStream()→ Clean restart → SuccessCommit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]