Skip to content

Commit

Permalink
add comment and remove unnecessary fake sync in test case
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Jan 21, 2025
1 parent d51e1a0 commit d619ef1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions kong/clustering/services/sync/validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ local function validate_deltas(deltas, is_full_sync)
-- validate entity
local dao = kong.db[delta_type]
if dao then
local ws_id = delta_entity.ws_id -- bypass ws_id field for validation
delta_entity.ws_id = nil
-- CP will insert ws_id into the entity, which will be validated as an
-- unknown field.
-- TODO: On the CP side, remove ws_id from the entity and set it only
-- in the delta.
local ws_id = delta_entity.ws_id
delta_entity.ws_id = nil -- clear ws_id

local ok, err_t = dao.schema:validate(delta_entity)

delta_entity.ws_id = ws_id
delta_entity.ws_id = ws_id -- restore ws_id

if not ok then
errs[#errs + 1] = { [delta_type] = err_t }
Expand Down
3 changes: 3 additions & 0 deletions kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ local function validate_references(self, input)
end


-- TODO: Completely implement validate_references_sync without associating it
-- to declarative config. Currently, we will use the dc-generated
-- foreign_references table to accelerate iterating over entity foreign keys.
function DeclarativeConfig.validate_references_sync(deltas, deltas_map, is_full_sync)
local errs = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ local function setup_bp()

-- init declarative config
if not cached_dc then
kong.sync = "fake sync to generate dc with sync_v2_enabled"
local err
cached_dc, err = declarative.new_config(kong.configuration)
assert(cached_dc, err)
Expand Down

0 comments on commit d619ef1

Please sign in to comment.