diff --git a/kong/runloop/events.lua b/kong/runloop/events.lua index d3b88fff1e4a..ab982cf1fae2 100644 --- a/kong/runloop/events.lua +++ b/kong/runloop/events.lua @@ -312,23 +312,25 @@ local function crud_wasm_handler(data, schema_name) return end + local updated = false + + -- always invalidate for filter_chain entity changes + if schema_name == "filter_chains" then + updated = true + -- cache is invalidated on service/route deletion to ensure we don't -- have oprhaned filter chain data cached - local is_delete = data.operation == "delete" - and (schema_name == "services" - or schema_name == "routes") + elseif schema_name == "services" or schema_name == "routes" + updated = data.operation == "delete" - local is_filter_plugin = false - if schema_name == "plugins" then + -- invalidate for changes to wasm filter plugin entities + elseif schema_name == "plugins" then local new_name = data.entity.name local old_name = data.old_entity and data.old_entity.name - is_filter_plugin = (new_name and wasm.filters_by_name[new_name]) or - (old_name and wasm.filters_by_name[old_name]) + updated = (new_name and wasm.filters_by_name[new_name]) or + (old_name and wasm.filters_by_name[old_name]) end - local updated = schema_name == "filter_chains" or is_delete or is_filter_plugin - - if updated then log(DEBUG, "[events] wasm filter chains updated, invalidating cache") core_cache:invalidate("filter_chains:version")