Skip to content

Commit

Permalink
fix: Fix wrong type of rate_limit in execute_script
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Apr 26, 2024
1 parent d61f52d commit e8947af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ai/backend/manager/api/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
local visit_count = redis.call('ZCARD', namespaced_id)
if id_type == "ip" then
local rate_limit = KEYS[3]
local rate_limit = tonumber(ARGV[3])
local score_threshold = rate_limit * 0.8
-- Add IP to suspicious_ips only if count is greater than score_threshold
if visit_count >= score_threshold then
redis.call('ZADD', 'suspicious_ips', count, id_value)
redis.call('ZADD', 'suspicious_ips', visit_count, id_value)
end
end
Expand Down Expand Up @@ -110,7 +110,7 @@ async def rlim_middleware(
"ratelimit",
_rlim_script,
["ip", ip_address],
[str(now), str(_rlim_window), rate_limit],
[str(now), str(_rlim_window), str(rate_limit)],
)
if ret is None:
remaining = rate_limit
Expand Down

0 comments on commit e8947af

Please sign in to comment.