Skip to content

Commit

Permalink
fix(sync): notify declarative:reconfigure events for full sync (#13860)
Browse files Browse the repository at this point in the history
With full sync (`wipe = true` in `do_sync()`), if we dont notify other workers with `declarative:reconfigure`, the registered callbacks in other workers will not be called, like updating `kong.default_workerspace`.

Note that when an empty-configured CP and DP start with incremental sync enabled, the DP will rebuild routers, plugins, and the balancer twice. This occurs because the DP currently calls do_sync() twice during a single sync operation. With incremental sync disabled, it rebuilds these components only once.

https://konghq.atlassian.net/browse/KAG-5812
  • Loading branch information
chobits authored Nov 13, 2024
1 parent 3d462b5 commit 945d333
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local declarative = require("kong.db.declarative")
local constants = require("kong.constants")
local concurrency = require("kong.concurrency")
local isempty = require("table.isempty")
local events = require("kong.runloop.events")


local insert_entity_for_txn = declarative.insert_entity_for_txn
Expand Down Expand Up @@ -327,6 +328,16 @@ local function do_sync()
kong.core_cache:purge()
kong.cache:purge()

-- Trigger other workers' callbacks like reconfigure_handler.
--
-- Full sync could rebuild route, plugins and balancer route, so their
-- hashes are nil.
local reconfigure_data = { kong.default_workspace, nil, nil, nil, }
local ok, err = events.declarative_reconfigure_notify(reconfigure_data)
if not ok then
return nil, err
end

else
for _, event in ipairs(crud_events) do
-- delta_type, crud_event_type, delta.entity, old_entity
Expand Down

1 comment on commit 945d333

@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:945d333017de64b3ea8f1dd5644af069de2db25d
Artifacts available https://github.com/Kong/kong/actions/runs/11809694795

Please sign in to comment.