Skip to content

Commit

Permalink
fix(rate-limiting): revert request-aware-table usage (#11746)
Browse files Browse the repository at this point in the history
* the request-aware-table was incorrectly used in this plugin, these
  tables are expected to be shared across requests and should not be
  limited to a single request.
  • Loading branch information
samugi authored Oct 12, 2023
1 parent 3417883 commit be9298d
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions kong/plugins/rate-limiting/policies/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local policy_cluster = require "kong.plugins.rate-limiting.policies.cluster"
local timestamp = require "kong.tools.timestamp"
local reports = require "kong.reports"
local redis = require "resty.redis"
local request_aware_table = require "kong.tools.request_aware_table"
local table_clear = require "table.clear"

local kong = kong
local pairs = pairs
Expand All @@ -18,26 +18,23 @@ local EMPTY_UUID = "00000000-0000-0000-0000-000000000000"
-- for `conf.sync_rate > 0`
local auto_sync_timer

local cur_usage = request_aware_table.new()
-- {
-- [[
-- [cache_key] = <integer>
-- ]]
-- }
local cur_usage = {
--[[
[cache_key] = <integer>
--]]
}

local cur_usage_expire_at = request_aware_table.new()
-- {
-- [[
-- [cache_key] = <integer>
-- ]]
-- }
local cur_usage_expire_at = {
--[[
[cache_key] = <integer>
--]]
}

local cur_delta = request_aware_table.new()
-- {
-- [[
-- [cache_key] = <integer>
-- ]]
-- }
local cur_delta = {
--[[
[cache_key] = <integer>
--]]
}


local function is_present(str)
Expand Down Expand Up @@ -141,9 +138,9 @@ local function get_redis_connection(conf)
end

local function clear_local_counter()
cur_usage:clear()
cur_usage_expire_at:clear()
cur_delta:clear()
table_clear(cur_usage)
table_clear(cur_usage_expire_at)
table_clear(cur_delta)
end

local function sync_to_redis(premature, conf)
Expand Down

1 comment on commit be9298d

@khcp-gha-bot
Copy link

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:be9298d789718e0f2142f8fb18056f92ee8517d0
Artifacts available https://github.com/Kong/kong/actions/runs/6493056609

Please sign in to comment.