Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): dynamically sets log level for timers pre-created by timer-ng #10133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kong-3.2.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = {
"lua-resty-ipmatcher == 0.6.1",
"lua-resty-acme == 0.10.1",
"lua-resty-session == 4.0.0",
"lua-resty-timer-ng == 0.2.0",
"lua-resty-timer-ng == 0.2.2",
}
build = {
type = "builtin",
Expand Down
4 changes: 4 additions & 0 deletions kong/api/routes/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ local function handle_put_log_level(self, broadcast)
return kong.response.exit(500, { message = message })
end

-- store in global _G table for timers pre-created by lua-resty-timer-ng
-- KAG-457 - find a better way to make this work with lua-resty-timer-ng
_G.log_level = log_level

return kong.response.exit(200, { message = "log level changed" })
end

Expand Down
30 changes: 30 additions & 0 deletions spec/02-integration/04-admin_api/22-debug_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ describe("Admin API - Kong debug route with strategy #" .. strategy, function()
paths = { "/" },
service = service_mockbin,
})
assert(bp.plugins:insert {
name = "datadog",
service = service_mockbin,
})

assert(helpers.start_kong {
database = strategy,
Expand Down Expand Up @@ -143,6 +147,19 @@ describe("Admin API - Kong debug route with strategy #" .. strategy, function()
"(20:unable to get local issuer certificate) " ..
"while SSL handshaking to upstream", true, 2)

-- e2e test: we are not printing lower than alert
helpers.clean_logfile()
res = assert(helpers.proxy_client():send {
method = "GET",
path = "/",
headers = {
Host = "mockbin.com",
},
})
assert.res_status(502, res)
-- from timers pre-created by timer-ng (datadog plugin)
assert.logfile().has.no.line("failed to send data to", true, 2)

-- go back to default (debug)
res = assert(helpers.admin_client():send {
method = "PUT",
Expand Down Expand Up @@ -179,6 +196,19 @@ describe("Admin API - Kong debug route with strategy #" .. strategy, function()
assert.logfile().has.line("upstream SSL certificate verify error: " ..
"(20:unable to get local issuer certificate) " ..
"while SSL handshaking to upstream", true, 30)

-- e2e test: we are printing higher than debug
helpers.clean_logfile()
res = assert(helpers.proxy_client():send {
method = "GET",
path = "/",
headers = {
Host = "mockbin.com",
},
})
assert.res_status(502, res)
-- from timers pre-created by timer-ng (datadog plugin)
assert.logfile().has.line("failed to send data to", true, 30)
end)

it("changes log level for traditional mode", function()
Expand Down