change: Improve results from admin API while GET all plugins#9580
Conversation
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
|
@monkeyDluffy6017 Please approve CI |
|
@monkeyDluffy6017 the failing tests are unrelated to the PR. Can you rerun CI? These tests are flaky |
|
@kayx23 Should we change the default behaviour of this interface? or just add a parameter |
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
Breaking changes aside:
But does this make sense? Why is |
Signed-off-by: revolyssup <[email protected]>
|
Current state of this PR reflects this proposal: #9577 (comment) |
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
|
@monkeyDluffy6017 ping |
Signed-off-by: revolyssup <[email protected]>
| local err = "failed to load plugin " .. name .. " in subsystem " .. subsystem | ||
| core.log.warn("failed to load plugin [", name, "] err: ", plugin) | ||
| return 400, {error_msg = "failed to load plugin " .. name} | ||
| return 400, {error_msg = err } |
There was a problem hiding this comment.
There is no need to return an error here? If the plugin doesn't exist, it is fine to return nil?
| function _M.get_plugins_list() | ||
| local plugins = core.config.local_conf().plugins | ||
| function _M.get_plugins_list(subsystem) | ||
| local http_plugins |
There was a problem hiding this comment.
Could you check the subsystem here?
There was a problem hiding this comment.
You mean before defining stream_plugins variable?
There was a problem hiding this comment.
@monkeyDluffy6017 The check is already performed here https://github.com/apache/apisix/pull/9580/files#diff-8baac20135bcefd8d1beffe08f44b5271bc1c717c6ab2e720a0e14cb1a02599dR262 before calling this function
| local plugin_name = "apisix.plugins." .. name | ||
| local ok, plugin = pcall(require, plugin_name) | ||
| if ok and plugin.priority then | ||
| priorities[name] = plugin.priority |
There was a problem hiding this comment.
can these two function be used here?
local plugin_get_http = require("apisix.plugin").get
local plugin_get_stream = require("apisix.plugin").get_stream
There was a problem hiding this comment.
Those functions are to get the entire plugin loaded with plugin.load(). Here we just need the names.
| local plugin_name = "apisix.stream.plugins." .. name | ||
| local ok, plugin = pcall(require, plugin_name) | ||
| if ok and plugin.priority then | ||
| priorities[name] = plugin.priority | ||
| table_insert(success, name) |
There was a problem hiding this comment.
Those functions are to get the entire plugin loaded with plugin.load(). Here we just need the names.
| | --------- | ----------------------------- | ------- | | ||
| | subsystem | The subsystem of the Plugins. | http | | ||
|
|
||
| The plugin can be filtered on subsystem so that the ({plugin_name}) is searched in the subsystem passed through query params. Note that this query parameter is not available on `/apisix/admin/plugins/list` |
There was a problem hiding this comment.
I think it's supported on /apisix/admin/plugins/list?
There was a problem hiding this comment.
It wasn't present present previously and was later added in the pull request. I removed the later comment.
| | --------- | -------------------------------------- | -------- | | ||
| | subsystem | 插件子系统。 | http | | ||
|
|
||
| 可以在子系统上过滤插件,以便在通过查询参数传递的子系统中搜索 ({plugin_name})。请注意,此查询参数在“/apisix/admin/plugins/list”上不可用 |
There was a problem hiding this comment.
I think it's supported on /apisix/admin/plugins/list?
There was a problem hiding this comment.
It wasn't present present previously and was later added in the pull request. I removed the later comment.
|
|
||
| 你可以使用 `/apisix/admin/plugins?all=true` 接口获取所有插件的所有属性,每个插件包括 `name`,`priority`,`type`,`schema`,`consumer_schema` 和 `version`。 | ||
|
|
||
| 默认情况下,该接口只返回 L7 插件。如果你需要获取 L4 / Stream 插件,需要使用 `/apisix/admin/plugins?all=true&subsystem=stream`。 | ||
| 您可以使用“/apisix/admin/plugins?all=true”API 获取所有插件的所有属性。查询参数 `?all=true` 将很快被弃用。 |
There was a problem hiding this comment.
Delete the whole tip, use the following one intead:
您可以使用 “/apisix/admin/plugins?all=true” 获取所有插件的所有属性。这个 API 将很快被弃用
Co-authored-by: Liu Wei <[email protected]>
Co-authored-by: Liu Wei <[email protected]>
Signed-off-by: revolyssup <[email protected]>
|
Please fix the doc lint |
Signed-off-by: revolyssup <[email protected]>
| local subsystem = arg["subsystem"] | ||
| if subsystem and subsystem ~= "http" and subsystem ~= "stream" then | ||
| return 400, {error_msg = "unsupported subsystem: "..subsystem} | ||
| end |
There was a problem hiding this comment.
| local subsystem = arg["subsystem"] | |
| if subsystem and subsystem ~= "http" and subsystem ~= "stream" then | |
| return 400, {error_msg = "unsupported subsystem: "..subsystem} | |
| end | |
| local subsystem = arg["subsystem"] or "http" | |
| if subsystem ~= "http" and subsystem ~= "stream" then | |
| return 400, {error_msg = "unsupported subsystem: "..subsystem} | |
| end |
| end | ||
| local plugin | ||
| -- By default search through http subsystems | ||
| subsystem = subsystem or "http" |
There was a problem hiding this comment.
delete
subsystem = subsystem or "http"
| local err = "failed to load plugin " .. name .. " in subsystem " .. subsystem | ||
| core.log.warn("failed to load plugin [", name, "] err: ", err) |
There was a problem hiding this comment.
The msg should be changed
| stream_plugins = core.config.local_conf().stream_plugins | ||
| end | ||
|
|
||
|
|
| if not plugin then | ||
| local err = "failed to load plugin " .. name .. " in subsystem " .. subsystem | ||
| core.log.warn("failed to load plugin [", name, "] err: ", err) | ||
| return 404, {error_msg = "plugin not found"} |
There was a problem hiding this comment.
"plugin " .. name .. " is not found in subsystem " .. subsystem
Signed-off-by: revolyssup <[email protected]>
Signed-off-by: revolyssup <[email protected]>
| @$(call func_echo_status, "$@ -> [ Start ]") | ||
| $(ENV_GIT) submodule update --init --recursive | ||
| prove -I../test-nginx/lib -I./ -r -s t/ | ||
| prove -I../test-nginx/lib -I./ -r -s t/admin/plugins.t |
There was a problem hiding this comment.
Why do you add this?
Signed-off-by: revolyssup <[email protected]>
Description
Fixes #9577
Checklist