-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
bug: The request-id plugin may have a bug #4460
Comments
@zuiyangqingzhou What is the exact logic of your upstream? Just reflecting the request headers? The request-id plugin just adds the id header on your demands. It won't change other things. Make sure your upstream doesn't contain its own |
This is the upstream logic, it just gets the header passed from apisix
You may not understand what I mean. What I mean is that the request-id passed by apisix to upstream is different from the request-id it returns to curl. Shouldn't this be a bug? I have a picture above you can look at it |
@zuiyangqingzhou hi, I repeated your steps, cc @tokers step 1: set curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri":"/get",
"plugins": {
"request-id": {
"header_name":"X-Request-Route-Id",
"include_in_response": true
}
},
"upstream":{
"nodes":{
"httpbin.org:80":1
},
"type":"roundrobin"
}
}' step 2: set curl http://127.0.0.1:9080/apisix/admin/global_rules/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"request-id": {
"header_name":"X-My-Request-id",
"include_in_response": true
}
}
}' step 3: send request curl -i 127.0.0.1:9080/get
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 429
Connection: keep-alive
Date: Wed, 23 Jun 2021 17:00:57 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Server: APISIX/2.6
X-My-Request-id: 2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a
X-Request-Route-Id: 2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a
{
"args": {},
"headers": {
"Accept": "*/*",
"Host": "127.0.0.1",
"User-Agent": "curl/7.71.1",
"X-Amzn-Trace-Id": "Root=1-60d368c9-7ef6036b6b2944281ae48465",
"X-Forwarded-Host": "127.0.0.1",
"X-My-Request-Id": "8509eca0-be8c-4e1f-9186-8427569adfd1",
"X-Request-Route-Id": "2a3c2d84-7e8f-4dcd-8d85-d175f0bb9d7a"
},
"origin": "127.0.0.1, 58.152.81.86",
"url": "http://127.0.0.1/get"
} I get the same error. by adding the log I found that the apisix/apisix/plugins/request-id.lua Lines 63 to 64 in 2707fda
request-id on route is executed later than the one on global_rule .
I think it should be explicitly stated that |
@zuiyangqingzhou Oh, gotcha, configuring I'd like to know your scenario that need two request-id. @tzssangglass Though it seems that configuring two request-id plugins don't make sense, I think the request-id header in response should be consistent with the one in request headers to upstream. |
Yes, it is very correct. This is what I want to express. Although the two request-ids are meaningless, it should be ensured that the request-id in the response is the same as the one passed to upstream. |
@zuiyangqingzhou Would you like to submit a PR to fix this? Thanks! |
I haven't mentioned a PR to apisix yet, I am a little nervous, but I can give it a try |
Issue description
When I enable the global request-id plugin and the request-id plugin on the route at the same time, there will be a BUG
Bug report without environment information will be ignored or closed.
apisix version
): 2.6uname -a
): Darwin Kernel Version 20.5.0nginx -V
oropenresty -V
): nginx version: openresty/1.19.3.2curl http://127.0.0.1:9090/v1/server_info
to get the info from server-info API): etcd Version: 3.4.16luarocks --version
):Minimal test code / Steps to reproduce the issue
Bug report without steps to reproduce will be ignored or closed.
Environment
As you can see, the X-My-Request-Id in the header returned by the request is different from the X-My-Request-Id obtained by upstream.
What's the actual result? (including assertion message & call stack if applicable)
What's the expected result?
The text was updated successfully, but these errors were encountered: