Skip to content

Commit

Permalink
fix(clustering): CP should support both v1 and v2 (#13805)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki authored Nov 5, 2024
1 parent 5e5256c commit 6cb8235
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
23 changes: 13 additions & 10 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,21 @@ 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.clustering then
-- full sync dp

local is_dp_full_sync_agent = process.type() == "privileged agent" and not kong.sync

if is_control_plane(kong.configuration) or -- CP needs to support both full and incremental sync
is_dp_full_sync_agent -- full sync is only enabled for DP if incremental sync is disabled
then
kong.clustering:init_worker()
end
return

-- DP full sync agent skips the rest of the init_worker
if is_dp_full_sync_agent then
return
end
end

kong.vault.init_worker()
Expand Down Expand Up @@ -987,12 +996,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
15 changes: 9 additions & 6 deletions spec/02-integration/09-hybrid_mode/01-sync_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ local uuid = require("kong.tools.uuid").uuid
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,7 +623,11 @@ describe("CP/DP #version check #" .. strategy, function()
end)
end)

describe("CP/DP config sync #" .. strategy, function()
--- XXX FIXME: enable inc_sync = on
-- skips the rest of the tests. We will fix them in a follow-up PR
local skip_inc_sync = inc_sync == "on" and pending or describe

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

Expand Down Expand Up @@ -736,7 +739,7 @@ describe("CP/DP config sync #" .. strategy, function()
end)
end)

describe("CP/DP labels #" .. strategy, function()
skip_inc_sync("CP/DP labels #" .. strategy, function()

lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations
Expand Down Expand Up @@ -799,7 +802,7 @@ describe("CP/DP labels #" .. strategy, function()
end)
end)

describe("CP/DP cert details(cluster_mtls = shared) #" .. strategy, function()
skip_inc_sync("CP/DP cert details(cluster_mtls = shared) #" .. strategy, function()
lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations

Expand Down Expand Up @@ -856,7 +859,7 @@ describe("CP/DP cert details(cluster_mtls = shared) #" .. strategy, function()
end)
end)

describe("CP/DP cert details(cluster_mtls = pki) #" .. strategy, function()
skip_inc_sync("CP/DP cert details(cluster_mtls = pki) #" .. strategy, function()
lazy_setup(function()
helpers.get_db_utils(strategy) -- runs migrations

Expand Down

1 comment on commit 6cb8235

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:6cb8235b72052173fb484d85475b65f193a85831
Artifacts available https://github.com/Kong/kong/actions/runs/11676583845

Please sign in to comment.