Skip to content

feat: Implement bypass based on caller type in the regional frontend regional rate limiter#7662

Merged
fimanishi merged 9 commits intocadence-workflow:masterfrom
fimanishi:implement-frontend-ratelimiter-bypass-based-on-caller-type
Feb 4, 2026
Merged

feat: Implement bypass based on caller type in the regional frontend regional rate limiter#7662
fimanishi merged 9 commits intocadence-workflow:masterfrom
fimanishi:implement-frontend-ratelimiter-bypass-based-on-caller-type

Conversation

@fimanishi
Copy link
Member

What changed?
Added bypass using callerType to regional frontend rate limiter #7654

Why?
Persistence rate limiter does discriminate between some call/caller types and provide specific quotas for that, but within user requests there is no discrimination. There may be situations that we need some requests to be allowed for debugging/mitigation purposes even if the rate limit has been reached. This change allows the definition of a list of caller type to be bypassed in the frontend regional rate limiter.

How did you test it?
Added tests to service/frontend/wrappers/ratelimited/ratelimit_test.go.

Potential risks

Release notes

Documentation Changes


Reviewer Validation

PR Description Quality (check these before reviewing code):

  • "What changed" provides a clear 1-2 line summary
    • Project Issue is linked
  • "Why" explains the full motivation with sufficient context
  • Testing is documented:
    • Unit test commands are included (with exact go test invocation)
    • Integration test setup/commands included (if integration tests were run)
    • Canary testing details included (if canary was mentioned)
  • Potential risks section is thoughtfully filled out (or legitimately N/A)
  • Release notes included if this completes a user-facing feature
  • Documentation needs are addressed (or noted if uncertain)

…rate limiter

Signed-off-by: fimanishi <fimanishi@gmail.com>

# Conflicts:
#	common/dynamicconfig/dynamicproperties/constants.go
Signed-off-by: fimanishi <fimanishi@gmail.com>
Signed-off-by: fimanishi <fimanishi@gmail.com>
@fimanishi fimanishi force-pushed the implement-frontend-ratelimiter-bypass-based-on-caller-type branch from 6b518d4 to 1eb05b0 Compare January 30, 2026 22:14
Signed-off-by: fimanishi <fimanishi@gmail.com>
visibilityRateLimiter quotas.Policy,
asyncRateLimiter quotas.Policy,
maxWorkerPollDelay dynamicproperties.DurationPropertyFnWithDomainFilter,
dc *dynamicconfig.Collection,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have the entire dynamicConfig inside the ratelimit? If we are only looking for a list of whitelist operations to bypass the ratelimiter, perhaps it makes more sense to only pass that list instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I think minimally we should align the way that we pass the maxWorkerPollDelay. Either pull both from the dynamicconfig or pass them both as functions.

visibilityRateLimiter quotas.Policy,
asyncRateLimiter quotas.Policy,
maxWorkerPollDelay dynamicproperties.DurationPropertyFnWithDomainFilter,
dc *dynamicconfig.Collection,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I think minimally we should align the way that we pass the maxWorkerPollDelay. Either pull both from the dynamicconfig or pass them both as functions.

}
}
if !policy.Allow(quotas.Info{Domain: domain}) {
callerInfo := types.GetCallerInfoFromContext(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to move this logic into the Limiter/Policy to avoid repeating it here and in the persistence wrapper?

It might be really complicated to do, so "no" is a valid answer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could create a wrapper that does it, but I would have to create a wrapper for policy and for limiter, which would reduce duplication but still is specific to each one. Let me give it a try

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I can try to just make this whole thing a method. It'll probably be better and I can use it for the wait as well

if ok := c.rateLimiter.Allow(); !ok {
callerInfo := types.GetCallerInfoFromContext({{(index $method.Params 0).Name}})
if c.shouldBypassRateLimit(callerInfo.GetCallerType()) {
if c.dc != nil && types.ShouldBypassRateLimit(callerInfo.GetCallerType(), c.dc.GetListProperty(dynamicproperties.RateLimiterBypassCallerTypes)()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I'd prefer for this to be in a normal Go function rather than as part of a template. The generated code tends to be less tested and can be an easy source of bugs that we would normally catch.

Signed-off-by: fimanishi <fimanishi@gmail.com>
Signed-off-by: fimanishi <fimanishi@gmail.com>
Signed-off-by: fimanishi <fimanishi@gmail.com>
Signed-off-by: fimanishi <fimanishi@gmail.com>
Signed-off-by: fimanishi <fimanishi@gmail.com>
@gitar-bot
Copy link

gitar-bot bot commented Feb 4, 2026

Code Review ✅ Approved

Well-structured refactoring that consolidates rate limiter bypass logic into a reusable CallerBypass component. Clean separation of concerns with proper nil handling, unified config key, and comprehensive test coverage across both persistence and frontend rate limiters.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@fimanishi fimanishi merged commit 8fc0d0b into cadence-workflow:master Feb 4, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants