pawarJayesh8511 opened a new issue #4924:
URL: https://github.com/apache/apisix/issues/4924
### Issue description
I have configured the following route, wherein
1. if the upstream is down i.e it either returns 500 or 502 or 503 then
APISIX should return status as 507. But, it is not happening like that.
2. if the upstream is not down, but, it throws the error with 500 status
then also, it should give the same status code as 507.
But, in both above cases, it is not working as expected.
Route:
{
"key":"\/apisix\/routes\/370045865856862098",
"createdIndex":1731,
"modifiedIndex":1738,
"value":{
"id":"370045865856862098",
"upstream_id":"369094337344046994",
"update_time":1630094440,
"name":"apibreaker",
"status":1,
"uris":[
"\/api\/breaker"
],
"create_time":1630094123,
"methods":[
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"plugins":{
"api-breaker":{
"disable":false,
"max_breaker_sec":5,
"unhealthy":{
"http_statuses":[
503,
500,
502
],
"failures":3
},
"healthy":{
"successes":3,
"http_statuses":[
200
]
},
"break_response_code":507
}
}
}
}
Response from upstream:
curl -X GET -i http://xxx.xxx.xx.1:9282/api/breaker
Output
HTTP/1.1 500
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sun, 29 Aug 2021 15:27:02 GMT
Connection: close
{"timestamp":"2021-08-29T15:27:02.474+0000","status":500,"error":"Internal
Server Error","message":"something went wrong","path":"/api/breaker"}
Response from APISIX gateway:
curl -X GET -i http://127.0.0.1:9080/api/breaker
Output
HTTP/1.1 500
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Date: Sun, 29 Aug 2021 15:33:21 GMT
Server: APISIX/2.8
X-APISIX-Upstream-Status: 500
{"timestamp":"2021-08-29T15:33:21.121+0000","status":500,"error":"Internal
Server Error","message":"something went wrong","path":"/api/breaker"}
Response is not giving 507 status code.
### Environment
- apisix version (cmd: apisix version): 2.8
- OS (cmd: uname -a): Linux my-machine 5.11.0-27-generic
- conf: removed user resty and add server header. #29~20.04.1-Ubuntu SMP Wed
Aug 11 15:58:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- OpenResty / Nginx version (cmd: nginx -V or openresty -V): nginx version:
openresty/1.19.9.1
- etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info
to get the info from server-info API): 3.4.0
- apisix-dashboard version, if have: 2.7
- luarocks version, if the issue is about installation (cmd: luarocks
--version): 3.4.0
### Steps to reproduce
I followed the steps in the
https://apisix.apache.org/docs/apisix/plugins/api-breaker
and, the route is:
{
"key":"\/apisix\/routes\/370045865856862098",
"createdIndex":1731,
"modifiedIndex":1738,
"value":{
"id":"370045865856862098",
"upstream_id":"369094337344046994",
"update_time":1630094440,
"name":"apibreaker",
"status":1,
"uris":[
"\/api\/breaker"
],
"create_time":1630094123,
"methods":[
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"plugins":{
"api-breaker":{
"disable":false,
"max_breaker_sec":5,
"unhealthy":{
"http_statuses":[
503,
500,
502
],
"failures":3
},
"healthy":{
"successes":3,
"http_statuses":[
200
]
},
"break_response_code":507
}
}
}
}
### Actual result
Response from upstream:
curl -X GET -i http://xxx.xxx.xx.1:9282/api/breaker
Output
HTTP/1.1 500
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sun, 29 Aug 2021 15:27:02 GMT
Connection: close
{"timestamp":"2021-08-29T15:27:02.474+0000","status":500,"error":"Internal
Server Error","message":"something went wrong","path":"/api/breaker"}
Response from APISIX gateway:
curl -X GET -i http://127.0.0.1:9080/api/breaker
Output
HTTP/1.1 500
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Date: Sun, 29 Aug 2021 15:33:21 GMT
Server: APISIX/2.8
X-APISIX-Upstream-Status: 500
{"timestamp":"2021-08-29T15:33:21.121+0000","status":500,"error":"Internal
Server Error","message":"something went wrong","path":"/api/breaker"}
Response is not giving 507 status code.
### Error log
2021/08/29 20:44:58 [error] 6062#6062: *212114 connect() failed (111:
Connection refused) while connecting to upstream, client: 127.0.0.1, server: _,
request: "GET /api/breaker HTTP/1.1", upstream:
"http://xxx.xxx.xx.1:9282/api/breaker", host: "127.0.0.1:9080"
2021/08/29 20:47:40 [error] 6061#6061: *220460 connect() failed (111:
Connection refused) while connecting to upstream, client: 127.0.0.1, server: _,
request: "GET /api/breaker HTTP/1.1", upstream:
"http://xxx.xxx.xx.1:9282/api/breaker", host: "127.0.0.1:9080"
2021/08/29 20:50:49 [error] 6062#6062: *230180 connect() failed (111:
Connection refused) while connecting to upstream, client: 127.0.0.1, server: _,
request: "GET /api/breaker HTTP/1.1", upstream:
"http://xxx.xxx.xxx.1:9282/api/breaker", host: "127.0.0.1:9080"
### Expected result
Response from APISIX gateway:
curl -X GET -i http://127.0.0.1:9080/api/breaker
Output
HTTP/1.1 507
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Date: Sun, 29 Aug 2021 15:33:21 GMT
Server: APISIX/2.8
X-APISIX-Upstream-Status: 507
{"timestamp":"2021-08-29T15:33:21.121+0000","status":500,"error":"Internal
Server Error","message":"something went wrong","path":"/api/breaker"}
Response is should give 507 status code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]