Skip to content

Commit

Permalink
chore(clustering): do not enable kong.sync.v2 when connecting dp is o…
Browse files Browse the repository at this point in the history
…lder than cp

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle committed Jan 23, 2025
1 parent 7a505ea commit e5d7b7f
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions kong/clustering/rpc/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ local callbacks = require("kong.clustering.rpc.callbacks")
local clustering_tls = require("kong.clustering.tls")
local constants = require("kong.constants")
local table_isempty = require("table.isempty")
local pl_tablex = require("pl.tablex")
local table_clone = require("table.clone")
local table_remove = table.remove
local cjson = require("cjson.safe")
local string_tools = require("kong.tools.string")

Expand All @@ -25,7 +26,7 @@ local ngx_log = ngx.log
local ngx_exit = ngx.exit
local ngx_time = ngx.time
local exiting = ngx.worker.exiting
local pl_tablex_makeset = pl_tablex.makeset
local pl_tablex_makeset = require("pl.tablex").makeset
local cjson_encode = cjson.encode
local cjson_decode = cjson.decode
local validate_client_cert = clustering_tls.validate_client_cert
Expand Down Expand Up @@ -188,10 +189,27 @@ function _M:_handle_meta_call(c, cert)
assert(type(info.kong_hostname) == "string")
assert(type(info.kong_conf) == "table")

local version = info.kong_version
local rpc_capabilities = self.callbacks:get_capabilities_list(version)
if KONG_VERSION > version then
local delta_index
for i, rpc_capability in ipairs(rpc_capabilities) do
if rpc_capability == "kong.sync.v2" then
delta_index = i
break
end
end
if delta_index then
rpc_capabilities = table_clone(rpc_capabilities)
table_remove(rpc_capabilities, delta_index)
end
table_clone(rpc_capabilities)
end

local payload = {
jsonrpc = jsonrpc.VERSION,
result = {
rpc_capabilities = self.callbacks:get_capabilities_list(),
rpc_capabilities = rpc_capabilities,
-- now we only support snappy
rpc_frame_encoding = RPC_SNAPPY_FRAMED,
},
Expand Down Expand Up @@ -239,7 +257,7 @@ function _M:_handle_meta_call(c, cert)
-- store DP's ip addr
self.client_info[node_id] = {
ip = ngx_var.remote_addr,
version = info.kong_version,
version = version,
labels = labels,
cert_details = cert_details,
}
Expand Down

0 comments on commit e5d7b7f

Please sign in to comment.