You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/08/29 15:05:34 UTC
[GitHub] [apisix] pawarJayesh8511 opened a new issue #4923: bug: serverless is executing the pre and post function but not calling the upstream api
pawarJayesh8511 opened a new issue #4923:
URL: https://github.com/apache/apisix/issues/4923
### Issue description
I have following route defined
{
"key":"\/apisix\/routes\/154",
"createdIndex":1134,
"modifiedIndex":1136,
"value":{
"upstream":{
"nodes":{
"xxx.xxx.xxx.1:9282":1
},
"type":"roundrobin",
"hash_on":"vars",
"scheme":"http",
"pass_host":"pass"
},
"priority":0,
"id":"154",
"update_time":1630033424,
"uri":"\/api\/serverless",
"status":1,
"create_time":1630033217,
"plugins":{
"serverless-pre-function":{
"functions":[
"local count = 1 return function() count = count + 1 ngx.say(count) end"
],
"phase":"access"
}
}
}
}
Output:
curl -i http://127.0.0.1:9080/api/serverless
HTTP/1.1 200 OK
Date: Sun, 29 Aug 2021 14:59:57 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: APISIX/2.8
2
### Environment
- apisix version (cmd: `apisix version`):
- OS (cmd: `uname -a`):
- OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
- etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
- apisix-dashboard version, if have:
- luarocks version, if the issue is about installation (cmd: `luarocks --version`):
### Steps to reproduce
I have following route defined step in https://apisix.apache.org/docs/apisix/plugins/serverless
Route is as follows:
{
"key":"\/apisix\/routes\/154",
"createdIndex":1134,
"modifiedIndex":1136,
"value":{
"upstream":{
"nodes":{
"xxx.xxx.xxx.1:9282":1
},
"type":"roundrobin",
"hash_on":"vars",
"scheme":"http",
"pass_host":"pass"
},
"priority":0,
"id":"154",
"update_time":1630033424,
"uri":"\/api\/serverless",
"status":1,
"create_time":1630033217,
"plugins":{
"serverless-pre-function":{
"functions":[
"local count = 1 return function() count = count + 1 ngx.say(count) end"
],
"phase":"access"
}
}
}
}
### Actual result
curl -i http://127.0.0.1:9080/api/serverless
Output:
HTTP/1.1 200 OK
Date: Sun, 29 Aug 2021 14:59:57 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: APISIX/2.8
2
### Error log
Please note, we don't have anything for in error.log file when we execute the "phase":"access"
But, when I tried with "phase":"log", I am getting the following error.
2021/08/29 20:27:52 [error] 6062#6062: *159428 failed to run log_by_lua*: [string "local count = 1 return function() count = cou..."]:1: API disabled in the context of log_by_lua*
stack traceback:
[C]: in function 'say'
[string "local count = 1 return function() count = cou..."]:1: in function 'func'
...apisix-2.8/apisix-2.8/apisix/plugins/serverless/init.lua:78: in function 'call_funcs'
...apisix-2.8/apisix-2.8/apisix/plugins/serverless/init.lua:129: in function 'phase_func'
...six/installation/apisix-2.8/apisix-2.8/apisix/plugin.lua:679: in function 'common_phase'
...pisix/installation/apisix-2.8/apisix-2.8/apisix/init.lua:681: in function 'http_log_phase'
log_by_lua(nginx.conf:279):2: in main chunk while logging request, client: 127.0.0.1, server: _, request: "GET /api/serverless HTTP/1.1", upstream: "http://192.168.56.1:9282/api/serverless", host: "127.0.0.1:9080"
### Expected result
Pre and post function should get called and also upstream actual end point should get called.
curl -i http://127.0.0.1:9080/api/serverless
`2
called the actual upstream endpoint for serverless`
This is not happening
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #4923: bug: serverless is executing the pre and post function but not calling the upstream api
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4923:
URL: https://github.com/apache/apisix/issues/4923
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #4923: bug: serverless is executing the pre and post function but not calling the upstream api
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4923:
URL: https://github.com/apache/apisix/issues/4923#issuecomment-907935094
When you generate the response before reaching the upstream (via `ngx.say` in this case), Nginx won't continue to proxy your request to the upstream.
Also `ngx.say` is not supported in the log phase, see https://github.com/openresty/lua-nginx-module#ngxsay
This is an Nginx's behavior, not relative to APISIX.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org