From 08be357cb4e71d6255cd6a8a9c27b5eb4a2d4773 Mon Sep 17 00:00:00 2001 From: ProBrian Date: Wed, 8 Jan 2025 16:47:34 +0800 Subject: [PATCH 1/3] fix(core): separate plugin server runtime data from kong configration which could not be cjson encoded --- kong/runloop/plugin_servers/process.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/kong/runloop/plugin_servers/process.lua b/kong/runloop/plugin_servers/process.lua index bde565d8c5c..d4d7852eefc 100644 --- a/kong/runloop/plugin_servers/process.lua +++ b/kong/runloop/plugin_servers/process.lua @@ -10,6 +10,7 @@ local cjson_decode = cjson.decode local SIGTERM = 15 +local server_rt = {} -- store runtime of plugin server like proc local _M = {} @@ -150,16 +151,19 @@ local function pluginserver_timer(premature, server_def) end kong.log.notice("[pluginserver] starting pluginserver process for ", server_def.name or "") - server_def.proc = assert(ngx_pipe.spawn("exec " .. server_def.start_command, { + local proc = assert(ngx_pipe.spawn("exec " .. server_def.start_command, { merge_stderr = true, })) + server_rt[server_def.name] = { + proc = proc, + } next_spawn = ngx.now() + 1 - server_def.proc:set_timeouts(nil, nil, nil, 0) -- block until something actually happens - kong.log.notice("[pluginserver] started, pid ", server_def.proc:pid()) + proc:set_timeouts(nil, nil, nil, 0) -- block until something actually happens + kong.log.notice("[pluginserver] started, pid ", proc:pid()) while true do - grab_logs(server_def.proc, server_def.name) - local ok, reason, status = server_def.proc:wait() + grab_logs(proc, server_def.name) + local ok, reason, status = proc:wait() -- exited with a non 0 status if ok == false and reason == "exit" and status == 127 then @@ -205,12 +209,13 @@ function _M.stop_pluginservers() -- only worker 0 manages plugin server processes if worker_id() == 0 then -- TODO move to privileged worker? for _, server_def in ipairs(kong_config.pluginservers) do - if server_def.proc then - local ok, err = server_def.proc:kill(SIGTERM) + local server = server_rt[server_def.name] + if server and server.proc then + local ok, err = server.proc:kill(SIGTERM) if not ok then kong.log.error("[pluginserver] failed to stop pluginserver '", server_def.name, ": ", err) end - kong.log.notice("[pluginserver] successfully stopped pluginserver '", server_def.name, "', pid ", server_def.proc:pid()) + kong.log.notice("[pluginserver] successfully stopped pluginserver '", server_def.name, "', pid ", server.proc:pid()) end end end From 44d2f92ba90c33f83e8011005a795ead1c19dd9c Mon Sep 17 00:00:00 2001 From: ProBrian Date: Wed, 8 Jan 2025 16:51:06 +0800 Subject: [PATCH 2/3] chore(changelog): add changelog --- .../kong/fix-admin-api-route-path-response-error.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml diff --git a/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml b/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml new file mode 100644 index 00000000000..4b7d9079186 --- /dev/null +++ b/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml @@ -0,0 +1,3 @@ +message: "Fixed an issue where fetching admin api root path returns 500 server error" +type: bugfix +scope: Core From cad5004d5d62abc6dfa5d5e7c7c4a8e13593c126 Mon Sep 17 00:00:00 2001 From: Guilherme Salazar Date: Wed, 22 Jan 2025 10:43:03 -0300 Subject: [PATCH 3/3] chore(changelog): update changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml --- .../unreleased/kong/fix-admin-api-route-path-response-error.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml b/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml index 4b7d9079186..d303a94dce9 100644 --- a/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml +++ b/changelog/unreleased/kong/fix-admin-api-route-path-response-error.yml @@ -1,3 +1,3 @@ -message: "Fixed an issue where fetching admin api root path returns 500 server error" +message: "Fixed an issue where a GET request to the Admin API root `/` path would return a 500 server error" type: bugfix scope: Core