@@ -12,7 +12,8 @@ local callbacks = require("kong.clustering.rpc.callbacks")
12
12
local clustering_tls = require (" kong.clustering.tls" )
13
13
local constants = require (" kong.constants" )
14
14
local table_isempty = require (" table.isempty" )
15
- local pl_tablex = require (" pl.tablex" )
15
+ local table_clone = require (" table.clone" )
16
+ local table_remove = table.remove
16
17
local cjson = require (" cjson.safe" )
17
18
local string_tools = require (" kong.tools.string" )
18
19
@@ -25,7 +26,7 @@ local ngx_log = ngx.log
25
26
local ngx_exit = ngx .exit
26
27
local ngx_time = ngx .time
27
28
local exiting = ngx .worker .exiting
28
- local pl_tablex_makeset = pl_tablex .makeset
29
+ local pl_tablex_makeset = require ( " pl.tablex " ) .makeset
29
30
local cjson_encode = cjson .encode
30
31
local cjson_decode = cjson .decode
31
32
local validate_client_cert = clustering_tls .validate_client_cert
@@ -188,10 +189,27 @@ function _M:_handle_meta_call(c, cert)
188
189
assert (type (info .kong_hostname ) == " string" )
189
190
assert (type (info .kong_conf ) == " table" )
190
191
192
+ local version = info .kong_version
193
+ local rpc_capabilities = self .callbacks :get_capabilities_list (version )
194
+ if KONG_VERSION > version then
195
+ local delta_index
196
+ for i , rpc_capability in ipairs (rpc_capabilities ) do
197
+ if rpc_capability == " kong.sync.v2" then
198
+ delta_index = i
199
+ break
200
+ end
201
+ end
202
+ if delta_index then
203
+ rpc_capabilities = table_clone (rpc_capabilities )
204
+ table_remove (rpc_capabilities , delta_index )
205
+ end
206
+ table_clone (rpc_capabilities )
207
+ end
208
+
191
209
local payload = {
192
210
jsonrpc = jsonrpc .VERSION ,
193
211
result = {
194
- rpc_capabilities = self . callbacks : get_capabilities_list () ,
212
+ rpc_capabilities = rpc_capabilities ,
195
213
-- now we only support snappy
196
214
rpc_frame_encoding = RPC_SNAPPY_FRAMED ,
197
215
},
@@ -239,7 +257,7 @@ function _M:_handle_meta_call(c, cert)
239
257
-- store DP's ip addr
240
258
self .client_info [node_id ] = {
241
259
ip = ngx_var .remote_addr ,
242
- version = info . kong_version ,
260
+ version = version ,
243
261
labels = labels ,
244
262
cert_details = cert_details ,
245
263
}
0 commit comments