diff --git a/kong/clustering/rpc/manager.lua b/kong/clustering/rpc/manager.lua index fb40ace1a6e..5cedc0d27fd 100644 --- a/kong/clustering/rpc/manager.lua +++ b/kong/clustering/rpc/manager.lua @@ -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") @@ -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 @@ -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, }, @@ -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, }