Skip to content

Commit

Permalink
fix(clustering): avoid 500 accessing v1 api when inc_sync enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki committed Oct 31, 2024
1 parent 5cab556 commit 5cdaed4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
20 changes: 10 additions & 10 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,18 @@ function Kong.init_worker()
kong.cache:invalidate_local(constants.ADMIN_GUI_KCONFIG_CACHE_KEY)
end

if process.type() == "privileged agent" and not kong.sync then
if kong.clustering then
-- full sync cp/dp
if kong.clustring then
-- full sync dp
-- "privileged agent" must be a DP worker
if process.type() == "privileged agent" and not kong.sync then
kong.clustering:init_worker()
-- DP privileged agent skips the rest of the init_worker
return

elseif is_control_plane(kong.configuration) then
-- CP needs to support both full and incremental sync
kong.clustering:init_worker()
end
return
end

kong.vault.init_worker()
Expand Down Expand Up @@ -987,12 +993,6 @@ function Kong.init_worker()
end

if kong.clustering then

-- full sync cp/dp
if not kong.sync then
kong.clustering:init_worker()
end

-- rpc and incremental sync
if kong.rpc and is_http_module then

Expand Down
8 changes: 7 additions & 1 deletion spec/02-integration/09-hybrid_mode/01-sync_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local KEY_AUTH_PLUGIN


--- XXX FIXME: enable inc_sync = on
for _, inc_sync in ipairs { "off" } do
for _, inc_sync in ipairs { "on", "off" } do
for _, strategy in helpers.each_strategy() do

describe("CP/DP communication #" .. strategy .. " inc_sync=" .. inc_sync, function()
Expand Down Expand Up @@ -624,6 +624,12 @@ describe("CP/DP #version check #" .. strategy, function()
end)
end)

-- skips the rest of the tests. We will fix them in a follow-up PR
if inc_sync == "on" then
pending("fix this!")
return
end

describe("CP/DP config sync #" .. strategy, function()
lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations
Expand Down

0 comments on commit 5cdaed4

Please sign in to comment.