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/02/24 17:52:16 UTC
[GitHub] [apisix] tzssangglass opened a new issue #3663: bug: script does not work
tzssangglass opened a new issue #3663:
URL: https://github.com/apache/apisix/issues/3663
### Issue description
I used the script, but the script did not execute, see the following test case
```
use t::APISIX 'no_plan';
repeat_each(1);
log_level('info');
no_long_string();
no_root_location();
run_tests;
__DATA__
=== TEST 1: add services
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/services/1',
ngx.HTTP_PUT,
[[{
"name": "script_test",
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
}
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 2: route binding service and route has script
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"service_id": 1,
"script": "local _M = {} \n function _M.access(api_ctx) \n ngx.log(ngx.INFO,\"hit access phase\") \n end \nreturn _M",
"uri": "/hello"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 3: hit route and trigger script
--- request
GET /hello
--- response_body
hello world
--- error_log eval
qr/loaded script_obj: \{"access":"function: 0x[\w]+"\}/
```
based on the documentation for the script, I think the script should be executed because it is bound to the route and neither the route nor the service has plugins configured
bugs may appear in https://github.com/apache/apisix/blob/16f017dfedebf8bf85ff8be9d48c05d088d21d0e/apisix/plugin.lua#L385
maybe this function should be preceded by code like this before return
```
if route_conf.value.script then
new_conf.value.script = route_conf.value.script
end
```
### Environment
* apisix version (cmd: `apisix version`): greater than 2.2, less than 2.3
* OS (cmd: `uname -a`): Centos 7
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): openresty/1.19.3.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): {"etcdserver":"3.4.13","etcdcluster":"3.4.0"}
* apisix-dashboard version, if have:
### Minimal test code / Steps to reproduce the issue
1.
2.
3.
### What's the actual result? (including assertion message & call stack if applicable)
### What's the expected result?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785886841
There is such a case: route has a script, service has a plugin, route is bound to service, then the service's plugin needs to be executed?
@membphis
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785783235
The route one is preferred.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis closed issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
membphis closed issue #3663:
URL: https://github.com/apache/apisix/issues/3663
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785645709
According to the script documentation, on the route, script and plugin are mutually exclusive, so if there is script on the route and plugins on the service, and the route is bound to the service, do you need to execute both script and plugins?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass edited a comment on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
tzssangglass edited a comment on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785499851
> PR is welcome!
assign to me
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785901586
got
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785497946
PR is welcome!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785499851
> PR is welcome!
assign to me
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #3663: bug: script does not work
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #3663:
URL: https://github.com/apache/apisix/issues/3663#issuecomment-785893757
> There is such a case: route has a script, service has a plugin, route is bound to service, then the service's plugin needs to be executed?
> @membphis
for your case, only `script` can be executed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org