Skip to content

Commit

Permalink
conf.cluster_incremental_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Sep 24, 2024
1 parent 28a1cb0 commit c36b29b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions kong/conf_loader/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ local CONF_PARSERS = {
cluster_use_proxy = { typ = "boolean" },
cluster_dp_labels = { typ = "array" },
cluster_rpc = { typ = "boolean" },
cluster_incremental_sync = { typ = "boolean" },
cluster_cjson = { typ = "boolean" },

kic = { typ = "boolean" },
Expand Down
5 changes: 5 additions & 0 deletions kong/conf_loader/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,11 @@ local function load(path, custom_conf, opts)
end
end

if not conf.cluster_rpc then
log.warn("Cluster incremental sync has been forcibly disabled")
conf.cluster_incremental_sync = false
end

-- initialize the dns client, so the globally patched tcp.connect method
-- will work from here onwards.
assert(require("kong.tools.dns")(conf))
Expand Down
13 changes: 8 additions & 5 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,11 @@ function Kong.init()

if config.cluster_rpc then
kong.rpc = require("kong.clustering.rpc.manager").new(config, kong.node.get_id())
kong.sync = require("kong.clustering.services.sync").new(db, is_control_plane(config))
kong.sync:init(kong.rpc)

if config.cluster_incremental_sync then
kong.sync = require("kong.clustering.services.sync").new(db, is_control_plane(config))
kong.sync:init(kong.rpc)
end

if is_data_plane(config) then
require("kong.clustering.services.debug").init(kong.rpc)
Expand Down Expand Up @@ -877,7 +880,7 @@ function Kong.init_worker()
kong.cache:invalidate_local(constants.ADMIN_GUI_KCONFIG_CACHE_KEY)
end

if process.type() == "privileged agent" and not kong.rpc then
if process.type() == "privileged agent" and not kong.sync then
if kong.clustering then
-- full sync cp/dp
kong.clustering:init_worker()
Expand Down Expand Up @@ -985,11 +988,11 @@ function Kong.init_worker()
if kong.clustering then

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

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

-- only available in http subsystem
local cluster_tls = require("kong.clustering.tls")
Expand Down
2 changes: 1 addition & 1 deletion kong/pdk/vault.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ local function new(self)
initialized = true

if self.configuration.database ~= "off" or -- postgres
self.configuration.role == "data_plane" and self.configuration.cluster_rpc -- incremental dp
self.configuration.role == "data_plane" and self.configuration.cluster_incremental_sync -- incremental dp
then
self.worker_events.register(handle_vault_crud_event, "crud", "vaults")
end
Expand Down
1 change: 1 addition & 0 deletions kong/templates/kong_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cluster_max_payload = 16777216
cluster_use_proxy = off
cluster_dp_labels = NONE
cluster_rpc = on
cluster_incremental_sync = on
cluster_cjson = off
lmdb_environment_path = dbless.lmdb
Expand Down

0 comments on commit c36b29b

Please sign in to comment.