Skip to content

Commit

Permalink
feat(clustering/rpc): update dp status after syncing (#14205)
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored Jan 22, 2025
1 parent 576cdc8 commit f657890
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ local function is_rpc_ready()
end


-- tell cp we already updated the version by rpc notification
local function update_status(ver)
local msg = { default = { version = ver, }, }

local ok, err = kong.rpc:notify("control_plane", "kong.sync.v2.get_delta", msg)
if not ok then
ngx_log(ngx_ERR, "update status notification failed: ", err)
end
end


local function do_sync()
if not is_rpc_ready() then
return nil, "rpc is not ready"
Expand Down Expand Up @@ -384,6 +395,8 @@ local function sync_once_impl(premature, retry_count)
return
end

local version_before_sync = get_current_version()

local _, err = sync_handler()

-- check if "kong.sync.v2.notify_new_version" updates the latest version
Expand All @@ -397,6 +410,12 @@ local function sync_once_impl(premature, retry_count)
local current_version = get_current_version()
if current_version >= latest_notified_version then
ngx_log(ngx_DEBUG, "version already updated")

-- version changed, we should update status
if version_before_sync ~= current_version then
update_status(current_version)
end

return
end

Expand Down

1 comment on commit f657890

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong-dev:f65789031aa111e3a6e71809fddb6beb0d531fdb
Artifacts available https://github.com/Kong/kong/actions/runs/12899190210

Please sign in to comment.