From 5eac36bb5d2a80670e4e7527f3ea986cf87f6a86 Mon Sep 17 00:00:00 2001 From: Joshua Schmid Date: Wed, 17 Jul 2024 13:10:23 +0200 Subject: [PATCH] Revert "fix(proxy-cache): changes age param (#12812)" This reverts commit 47074659d2996236cce2657bbb503234a788731a. --- changelog/unreleased/kong/fix-age-header.yml | 3 -- kong-3.8.0-0.rockspec | 1 - kong/clustering/compat/checkers.lua | 12 ------ .../compat/response_headers_translation.lua | 13 ------ kong/plugins/proxy-cache/schema.lua | 2 +- .../09-hybrid_mode/09-config-compat_spec.lua | 40 ------------------- .../31-proxy-cache/02-access_spec.lua | 2 +- 7 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 changelog/unreleased/kong/fix-age-header.yml delete mode 100644 kong/plugins/proxy-cache/clustering/compat/response_headers_translation.lua diff --git a/changelog/unreleased/kong/fix-age-header.yml b/changelog/unreleased/kong/fix-age-header.yml deleted file mode 100644 index f3db9eba9bef..000000000000 --- a/changelog/unreleased/kong/fix-age-header.yml +++ /dev/null @@ -1,3 +0,0 @@ -message: "proxy-cache response_headers age schema parameter changed from age to Age." -type: bugfix -scope: "Plugin" diff --git a/kong-3.8.0-0.rockspec b/kong-3.8.0-0.rockspec index 4b718378a32e..8581f9cf0f92 100644 --- a/kong-3.8.0-0.rockspec +++ b/kong-3.8.0-0.rockspec @@ -548,7 +548,6 @@ build = { ["kong.plugins.proxy-cache.api"] = "kong/plugins/proxy-cache/api.lua", ["kong.plugins.proxy-cache.strategies"] = "kong/plugins/proxy-cache/strategies/init.lua", ["kong.plugins.proxy-cache.strategies.memory"] = "kong/plugins/proxy-cache/strategies/memory.lua", - ["kong.plugins.proxy-cache.clustering.compat.response_headers_translation"] = "kong/plugins/proxy-cache/clustering/compat/response_headers_translation.lua", ["kong.plugins.grpc-web.deco"] = "kong/plugins/grpc-web/deco.lua", ["kong.plugins.grpc-web.handler"] = "kong/plugins/grpc-web/handler.lua", diff --git a/kong/clustering/compat/checkers.lua b/kong/clustering/compat/checkers.lua index 02c57c98060e..a3418eb0b971 100644 --- a/kong/clustering/compat/checkers.lua +++ b/kong/clustering/compat/checkers.lua @@ -26,18 +26,6 @@ local compatible_checkers = { { 3008000000, --[[ 3.8.0.0 ]] function (config_table, dp_version, log_suffix) local has_update - local adapter = require("kong.plugins.proxy-cache.clustering.compat.response_headers_translation").adapter - for _, plugin in ipairs(config_table.plugins or {}) do - if plugin.name == 'proxy-cache' then - has_update = adapter(plugin.config) - if has_update then - log_warn_message('adapts ' .. plugin.name .. ' plugin response_headers configuration to older version', - 'revert to older schema', - dp_version, log_suffix) - end - end - end - for _, plugin in ipairs(config_table.plugins or {}) do if plugin.name == 'aws-lambda' then local config = plugin.config diff --git a/kong/plugins/proxy-cache/clustering/compat/response_headers_translation.lua b/kong/plugins/proxy-cache/clustering/compat/response_headers_translation.lua deleted file mode 100644 index 56c602f23bb5..000000000000 --- a/kong/plugins/proxy-cache/clustering/compat/response_headers_translation.lua +++ /dev/null @@ -1,13 +0,0 @@ -local function adapter(config_to_update) - if config_to_update.response_headers["Age"] ~= nil then - config_to_update.response_headers.age = config_to_update.response_headers["Age"] - config_to_update.response_headers["Age"] = nil - return true - end - - return false -end - -return { - adapter = adapter -} diff --git a/kong/plugins/proxy-cache/schema.lua b/kong/plugins/proxy-cache/schema.lua index 34efa9648b56..768e6f06975f 100644 --- a/kong/plugins/proxy-cache/schema.lua +++ b/kong/plugins/proxy-cache/schema.lua @@ -78,7 +78,7 @@ return { description = "Caching related diagnostic headers that should be included in cached responses", type = "record", fields = { - { ["Age"] = {type = "boolean", default = true} }, + { age = {type = "boolean", default = true} }, { ["X-Cache-Status"] = {type = "boolean", default = true} }, { ["X-Cache-Key"] = {type = "boolean", default = true} }, }, diff --git a/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua b/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua index b6cd68b98618..f6e516864f1f 100644 --- a/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua +++ b/spec/02-integration/09-hybrid_mode/09-config-compat_spec.lua @@ -479,46 +479,6 @@ describe("CP/DP config compat transformations #" .. strategy, function() admin.plugins:remove({ id = response_rl.id }) end) end) - - describe("proxy-cache plugin", function() - it("rename age field in response_headers config from age to Age", function() - -- [[ 3.8.x ]] -- - local response_rl = admin.plugins:insert { - name = "proxy-cache", - enabled = true, - config = { - response_code = { 200, 301, 404 }, - request_method = { "GET", "HEAD" }, - content_type = { "text/plain", "application/json" }, - cache_ttl = 300, - strategy = "memory", - cache_control = false, - memory = { - dictionary_name = "kong_db_cache", - }, - -- [[ age field renamed to Age - response_headers = { - ["Age"] = true, - ["X-Cache-Status"] = true, - ["X-Cache-Key"] = true - } - -- ]] - } - } - - local expected_response_rl_prior_38 = cycle_aware_deep_copy(response_rl) - expected_response_rl_prior_38.config.response_headers = { - ["age"] = true, - ["X-Cache-Status"] = true, - ["X-Cache-Key"] = true - } - - do_assert(uuid(), "3.7.0", expected_response_rl_prior_38) - - -- cleanup - admin.plugins:remove({ id = response_rl.id }) - end) - end) end) describe("ai plugins", function() diff --git a/spec/03-plugins/31-proxy-cache/02-access_spec.lua b/spec/03-plugins/31-proxy-cache/02-access_spec.lua index 665e23fade03..1dc0c5bb9305 100644 --- a/spec/03-plugins/31-proxy-cache/02-access_spec.lua +++ b/spec/03-plugins/31-proxy-cache/02-access_spec.lua @@ -329,7 +329,7 @@ do content_type = { "text/plain", "application/json" }, [policy] = policy_config, response_headers = { - ["Age"] = false, + age = false, ["X-Cache-Status"] = false, ["X-Cache-Key"] = false },