ratelimit: eviction path untested and comment/policy mismatch #529
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd#529
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
TestEvictionBoundsMapgenerates IPs viafmt.Sprintf("10.0.0.%d", i%256)— only 256 distinct keys againstmaxIPs = 1024, solen(l.limiters) >= maxIPsis never reached andevictOneLockedis never exercised; the test passes trivially. The eviction path (the trickiest logic) is untested. Also,forIP's comment says "oldest-inserted bucket is dropped" but the implementation evicts the bucket with fewest remaining tokens.Context: PR #526 (
internal/ratelimit/ratelimit_test.go,internal/ratelimit/ratelimit.go:80).Suggested fix: generate more than
maxIPsunique IPs so eviction actually triggers, and align the comment with the fewest-tokens policy.