-
Notifications
You must be signed in to change notification settings - Fork 170
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
[THREESCALE-9320] Conditional policy evaluating incorrectly: second policy in policy chain that implement export() always triggers #1485
[THREESCALE-9320] Conditional policy evaluating incorrectly: second policy in policy chain that implement export() always triggers #1485
Conversation
8946c81
to
7d51694
Compare
This commit from this PR 32d110e |
I have changed the first request to |
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
the apicast-config.json for the Request unbuffered policy is invalid json. FYI. |
Sorry to say that the verification steps for the Request unbuffered policy do not work for me. (Even after fixing the json issue with the apicast-config.json) When the conditional policy activating header |
With this change, the policy will stil works regardless of it position in the chain.
7d51694
to
967d0c8
Compare
Fixed
Updated verification steps for request_unbuffered policy |
Still not working. Sorry to say. But I found the issue 🎉 The file is too small that apicast can read it from one shot so does not need to do transfer encoding chunked. When I tried with 1M file, it worked as expected. The request with the header activating the conditional policy is not correct in the verifucation steps. I used this one:
|
My bad, I just realized I was using a 4k file this whole time. Update verification steps to reflect comments |
What
Fix https://issues.redhat.com/browse/THREESCALE-9320
An interesting side effect of this PR is that it also fixes the following problems
https://issues.redhat.com/browse/THREESCALE-8146
https://issues.redhat.com/browse/THREESCALE-8149
Why
When included in the policy chain, conditional policy will construct an internal policy chain with a list of policies.
When APIcast build a shared context, it will then call export() on the chain, including the chain constructed by the conditional policy. This means that any policy that implements export function will be triggered regardless of what the user sets the conditions for.
We can avoid this by moving the context export to a different phase. But first let check their current phases
apicast/apicast.lua
apicast/proxy.lua
Verification steps
Upstream connection policy
You should receive
HTTP/1.1 200 OK
You should receive
HTTP/1.1 504 Gateway Time-out
Retry policy
APICAST_UPSTREAM_RETRY_CASES="error http_503 http_504"
You should receive
HTTP/1.1 504 Gateway Time-out
immediatelyCheck the log and confirm that APIcast retry the request 3 times
Camel proxy
Expected response
Expected response
HTTP Proxy policy
Request unbuffered policy
The upstream returns 200, and checking
example
service log, you should see that APIcast send request with Content-Lenght headerThis time we can see that upstream return 200 and APIcast send request to upstream with
Transfer-encoding: chunked
header