-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
refactor(clustering/rpc): code clean of full sync in rpc #13823
Open
chronolaw
wants to merge
5
commits into
master
Choose a base branch
from
refactor/clean_rpc_full_sync
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -39,13 +39,25 @@ function _M.new(strategy) | |||||
end | ||||||
|
||||||
|
||||||
function _M:init_cp(manager) | ||||||
local purge_delay = manager.conf.cluster_data_plane_purge_delay | ||||||
local function inc_sync_result(res) | ||||||
return { default = { deltas = res, wipe = false, }, } | ||||||
end | ||||||
|
||||||
local function gen_delta_result(res, wipe) | ||||||
return { default = { deltas = res, wipe = wipe, }, } | ||||||
|
||||||
local function full_sync_result() | ||||||
local deltas, err = declarative.export_config_sync() | ||||||
if not deltas then | ||||||
return nil, err | ||||||
end | ||||||
|
||||||
-- wipe dp lmdb, full sync | ||||||
return { default = { deltas = deltas, wipe = true, }, } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Otherwise remove the function above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked offline, it is not a blocker. |
||||||
end | ||||||
|
||||||
|
||||||
function _M:init_cp(manager) | ||||||
local purge_delay = manager.conf.cluster_data_plane_purge_delay | ||||||
|
||||||
-- CP | ||||||
-- Method: kong.sync.v2.get_delta | ||||||
-- Params: versions: list of current versions of the database | ||||||
|
@@ -97,16 +109,11 @@ function _M:init_cp(manager) | |||||
", current_version: ", default_namespace_version, | ||||||
", forcing a full sync") | ||||||
|
||||||
|
||||||
local deltas, err = declarative.export_config_sync() | ||||||
if not deltas then | ||||||
return nil, err | ||||||
end | ||||||
|
||||||
-- wipe dp lmdb, full sync | ||||||
return gen_delta_result(deltas, true) | ||||||
return full_sync_result() | ||||||
end | ||||||
|
||||||
-- do we need an incremental sync? | ||||||
|
||||||
local res, err = self.strategy:get_delta(default_namespace_version) | ||||||
if not res then | ||||||
return nil, err | ||||||
|
@@ -117,13 +124,13 @@ function _M:init_cp(manager) | |||||
"[kong.sync.v2] no delta for node_id: ", node_id, | ||||||
", current_version: ", default_namespace_version, | ||||||
", node is already up to date" ) | ||||||
return gen_delta_result(res, false) | ||||||
return inc_sync_result(res) | ||||||
end | ||||||
|
||||||
-- some deltas are returned, are they contiguous? | ||||||
if res[1].version == default_namespace_version + 1 then | ||||||
-- doesn't wipe dp lmdb, incremental sync | ||||||
return gen_delta_result(res, false) | ||||||
return inc_sync_result(res) | ||||||
end | ||||||
|
||||||
-- we need to full sync because holes are found | ||||||
|
@@ -135,13 +142,7 @@ function _M:init_cp(manager) | |||||
", current_version: ", default_namespace_version, | ||||||
", forcing a full sync") | ||||||
|
||||||
local deltas, err = declarative.export_config_sync() | ||||||
if not deltas then | ||||||
return nil, err | ||||||
end | ||||||
|
||||||
-- wipe dp lmdb, full sync | ||||||
return gen_delta_result(deltas, true) | ||||||
return full_sync_result() | ||||||
end) | ||||||
end | ||||||
|
||||||
|
@@ -364,6 +365,8 @@ end | |||||
|
||||||
|
||||||
function _M:sync_once(delay) | ||||||
--- XXX TODO: check rpc connection is ready | ||||||
|
||||||
return start_sync_timer(ngx.timer.at, delay or 0) | ||||||
end | ||||||
|
||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is not very proper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline, it is not a blocker.