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/05/26 14:23:23 UTC
[GitHub] [apisix] Firstsawyou opened a new issue #4314: bug: plugin hot reloading does not take effect
Firstsawyou opened a new issue #4314:
URL: https://github.com/apache/apisix/issues/4314
### Issue description
After modifying the code of the plugin, after performing the following operations according to the [plugins.md](https://github.com/apache/apisix/blob/master/docs/en/latest/plugins.md#hot-reload) document, the hot loading of the apisix plugin did not take effect.
```shell
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
```
### Environment
Bug report without environment information will be ignored or closed.
* apisix version (cmd: `apisix version`): 2.6
* OS (cmd: `uname -a`): Linux
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): nginx version: 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): 3.4.0
* apisix-dashboard version, if have:
* luarocks version, if the issue is about installation (cmd: `luarocks --version`): 3.4.0
### Minimal test code / Steps to reproduce the issue
Bug report without steps to reproduce will be ignored or closed.
1. Modify the `limit-count` plugin code (add a warning log)
```sh
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -156,7 +156,7 @@ end
function _M.access(conf, ctx)
- core.log.info("ver: ", ctx.conf_version)
+ core.log.warn("ver: ", ctx.conf_version, "hello world, 123456")
local lim, err = core.lrucache.plugin_ctx(lrucache, ctx, conf.policy, create_limit_obj, conf)
if not lim then
```
2. Create a route and bind the plugin
```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/get",
"plugins": {
"limit-count": {
"count": 3,
"time_window": 10,
"rejected_code": 503,
"key": "remote_addr"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'
```
3. Execute hot load request
```shell
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
```
4. Request a test
```shell
curl http://127.0.0.1:9080/get -i
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 300
Connection: keep-alive
X-RateLimit-Limit: 3
X-RateLimit-Remaining: 2
```
5. View the error.log log (no log output)
```
2021/05/26 22:13:18 [warn] 939867#939867: *164198 [lua] init.lua:290: sync_local_conf_to_etcd(): sync local conf to etcd, context: ngx.timer
```
6. When the following code is commented, the plugin hot loading will take effect
```sh
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 5b4337c..7be84ac 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -167,7 +167,7 @@ local function load(plugin_names)
-- the same configure may be synchronized more than one
if plugins_eq(local_plugins_hash, processed) then
core.log.info("plugins not changed")
- return true
+ -- return true
end
core.log.warn("new plugins: ", core.json.delay_encode(processed))
```
### What's the actual result? (including assertion message & call stack if applicable)
After the hot reload request is executed, the code of the modified plugin cannot take effect.
### What's the expected result?
After the hot load request is executed, the modification of the plugin code can take effect in time.
--
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] dabue closed issue #4314: bug: plugin hot reloading does not take effect
Posted by GitBox <gi...@apache.org>.
dabue closed issue #4314:
URL: https://github.com/apache/apisix/issues/4314
--
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] Firstsawyou commented on issue #4314: bug: plugin hot reloading does not take effect
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4314:
URL: https://github.com/apache/apisix/issues/4314#issuecomment-848899640
@spacewander
I think the code here should be removed so that it can support hot loading after modifying the plugin code. right?
https://github.com/apache/apisix/blob/master/apisix/plugin.lua#L167-L171
--
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