Skip to content

Commit

Permalink
fix(cp) do a pcall for all calls to export_deflated_reconfigure_payload
Browse files Browse the repository at this point in the history
We are already wrapping some calls to
`export_deflated_reconfigure_payload()` inside a pcall in the
`control_plane.lua` file. This change is doing a pcall in all the
remaining calls to `export_deflated_reconfigure_payload()` in this file
to avoid the CP crash whenever we find errors during initialization of
modules for example.
  • Loading branch information
gruceo authored and kikito committed Apr 22, 2022
1 parent 6f20f2f commit 3c89fa1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kong/clustering/control_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ function _M:handle_cp_websocket()
self.clients[wb] = queue

if not self.deflated_reconfigure_payload then
_, err = self:export_deflated_reconfigure_payload()
local ok, _, err = pcall(self.export_deflated_reconfigure_payload, self)
if not ok then
ngx_log(ngx_ERR, _log_prefix, "unable to export initial config from database: ", err, log_suffix)
end
end

if self.deflated_reconfigure_payload then
Expand Down Expand Up @@ -654,8 +657,8 @@ local function push_config_loop(premature, self, push_config_semaphore, delay)
return
end

local _, err = self:export_deflated_reconfigure_payload()
if err then
local ok, err = pcall(self.export_deflated_reconfigure_payload, self)
if not ok then
ngx_log(ngx_ERR, _log_prefix, "unable to export initial config from database: ", err)
end

Expand Down

0 comments on commit 3c89fa1

Please sign in to comment.