Skip to content

Commit

Permalink
chore(clustering/db): reduce log flooding on clustering and schema va…
Browse files Browse the repository at this point in the history
…lidation

### Summary

On control plane there was a debug log written on every second on every worker
that had no connected clients. This will now only log it once per worker, until
number of connected clients changes.

The schema validation also had a thing called unvalidated fields that caused
huge amounts of logs to be written with large config import / validation.

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle committed Jun 26, 2023
1 parent 9a95a32 commit c24746f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 10 additions & 1 deletion kong/clustering/control_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ local RECONFIGURE_TYPE = "RECONFIGURE"
local _log_prefix = "[clustering] "


local no_connected_clients_logged


local function handle_export_deflated_reconfigure_payload(self)
ngx_log(ngx_DEBUG, _log_prefix, "exporting config")

Expand Down Expand Up @@ -485,14 +488,20 @@ local function push_config_loop(premature, self, push_config_semaphore, delay)
end

if isempty(self.clients) then
ngx_log(ngx_DEBUG, _log_prefix, "skipping config push (no connected clients)")
if not no_connected_clients_logged then
ngx_log(ngx_DEBUG, _log_prefix, "skipping config push (no connected clients)")
no_connected_clients_logged = true
end
sleep(1)
-- re-queue the task. wait until we have clients connected
if push_config_semaphore:count() <= 0 then
push_config_semaphore:post()
end

goto continue

else
no_connected_clients_logged = nil
end

ok, err = pcall(self.push_config, self)
Expand Down
5 changes: 2 additions & 3 deletions kong/db/schema/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,8 @@ validate_fields = function(self, input)
errors[k] = validation_errors.SCHEMA_CANNOT_VALIDATE
kong.log.debug(errors[k], ": ", err)
end
elseif self.unvalidated_fields[k]() then
kong.log.debug("ignoring validation on ", k, " field")
else

elseif not self.unvalidated_fields[k]() then
field, err = resolve_field(self, k, field, subschema)
if field then
_, errors[k] = self:validate_field(field, v)
Expand Down

0 comments on commit c24746f

Please sign in to comment.