From 612648cab67aad86595dff1855218ff598faf761 Mon Sep 17 00:00:00 2001 From: Murillo <103451714+gruceo@users.noreply.github.com> Date: Wed, 13 Apr 2022 11:28:29 -0300 Subject: [PATCH] fix(wrpc) do a pcall for all export_deflated_reconfigure_payload calls We are already wrapping some calls to `export_deflated_reconfigure_payload()` inside a pcall in the `wrpc_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. --- kong/clustering/wrpc_control_plane.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kong/clustering/wrpc_control_plane.lua b/kong/clustering/wrpc_control_plane.lua index 9ef85eb2774..20956121528 100644 --- a/kong/clustering/wrpc_control_plane.lua +++ b/kong/clustering/wrpc_control_plane.lua @@ -171,8 +171,8 @@ end function _M:push_config_one_client(client) if not self.config_call_rpc or not self.config_call_args then - local payload, err = self:export_deflated_reconfigure_payload() - if not payload then + local ok, err = pcall(self.export_deflated_reconfigure_payload, self) + if not ok then ngx_log(ngx_ERR, _log_prefix, "unable to export config from database: ", err) return end @@ -558,8 +558,8 @@ local function push_config_loop(premature, self, push_config_semaphore, delay) end do - 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 end