Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clustering/rpc): always sync when rpc connected #14070

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions kong/clustering/data_plane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ function _M:init_worker(basic_info)

-- if rpc is ready we will check then decide how to sync
worker_events.register(function(capabilities_list)
-- we only check once
if self.inited then
return
end

local has_sync_v2

-- check cp's capabilities
Expand All @@ -116,10 +111,15 @@ function _M:init_worker(basic_info)
return
end

ngx_log(ngx_WARN, "sync v1 is enabled due to rpc sync can not work.")
-- we only check once
if self.inited then
return
end

self.inited = true

ngx_log(ngx_WARN, "sync v1 is enabled due to rpc sync can not work.")

-- only run in process which worker_id() == 0
start_communicate()

Expand Down
14 changes: 7 additions & 7 deletions kong/clustering/services/sync/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ function _M:init_worker()

-- if rpc is ready we will start to sync
worker_events.register(function(capabilities_list)
-- we only check once
if self.inited then
return
end

local has_sync_v2

-- check cp's capabilities
Expand All @@ -78,11 +73,16 @@ function _M:init_worker()
return
end

self.inited = true

-- sync to CP ASAP
assert(self.rpc:sync_once(FIRST_SYNC_DELAY))

-- we only check once
if self.inited then
return
end

self.inited = true

assert(self.rpc:sync_every(EACH_SYNC_DELAY))

end, "clustering:jsonrpc", "connected")
Expand Down
Loading