diff --git a/kong/clustering/services/sync/validate.lua b/kong/clustering/services/sync/validate.lua index 203509e9d90..8b5aa91ccf9 100644 --- a/kong/clustering/services/sync/validate.lua +++ b/kong/clustering/services/sync/validate.lua @@ -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 } diff --git a/kong/db/schema/others/declarative_config.lua b/kong/db/schema/others/declarative_config.lua index 4ab298acfb8..e564104beca 100644 --- a/kong/db/schema/others/declarative_config.lua +++ b/kong/db/schema/others/declarative_config.lua @@ -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 = {} diff --git a/spec/02-integration/18-hybrid_rpc/06-validate_deltas_spec.lua b/spec/02-integration/18-hybrid_rpc/06-validate_deltas_spec.lua index 96e050989f4..9d8327692c0 100644 --- a/spec/02-integration/18-hybrid_rpc/06-validate_deltas_spec.lua +++ b/spec/02-integration/18-hybrid_rpc/06-validate_deltas_spec.lua @@ -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)