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 2022/03/07 01:33:15 UTC
[GitHub] [apisix] tzssangglass edited a comment on issue #6520: bug: the destroy function of plugin cant be called
tzssangglass edited a comment on issue #6520:
URL: https://github.com/apache/apisix/issues/6520#issuecomment-1060101548
add log output
```lua
core.log.info(plugin_name, " destroy")
```
on https://github.com/apache/apisix/blob/492f782d9fae719b3a20e0d65c275962bcdcaab9/apisix/plugins/example-plugin.lua#L71-L72
and use below test cases
```
use t::APISIX 'no_plan';
use Cwd qw(cwd);
repeat_each(1);
no_long_string();
no_root_location();
no_shuffle();
log_level("info");
add_block_preprocessor(sub {
my ($block) = @_;
my $user_yaml_config = <<_EOC_;
apisix:
node_listen: 1984
_EOC_
$block->set_value("yaml_config", $user_yaml_config);
});
run_tests;
__DATA__
=== TEST 1: set route with correct token
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").req_self_with_http
local res, err = t(
'/apisix/admin/routes/1',
"PUT",
[[{
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
},
"plugins": {
"example-plugin": {
"i": 11,
"ip": "127.0.0.1",
"port": 1981
}
},
"uri": "/index.html"
}]],
{x_api_key = "edd1c9f034335f136f87ad84b625c8f1"}
)
if res.status > 299 then
ngx.status = res.status
end
ngx.say("done")
}
}
--- request
GET /t
--- response_body
done
--- no_error_log
[error]
=== TEST 2: reload plugins with api key(cookie)
--- request
PUT /apisix/admin/plugins/reload
--- more_headers
X-API-KEY: edd1c9f034335f136f87ad84b625c8f1
--- error_code: 200
--- no_error_log
[error]
```
you will found
```
2022/03/07 09:27:01 [info] 42098#74904228: *23 [lua] example-plugin.lua:72: destroy(): example-plugin destroy, client: 127.0.0.1, server: localhost, request: "PUT /apisix/admin/plugins/reload HTTP/1.1", host: "localhost"
```
appeared twice.
The first call is before adding the plugin, and the second call is before hot reload.
I don't think there is a problem as you say.
--
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