Skip to content

ratelimit: per-descriptor hits_addend for route config#37972

Closed
mathetake wants to merge 8 commits intoenvoyproxy:mainfrom
mathetake:hitsaddend
Closed

ratelimit: per-descriptor hits_addend for route config#37972
mathetake wants to merge 8 commits intoenvoyproxy:mainfrom
mathetake:hitsaddend

Conversation

@mathetake
Copy link
Copy Markdown
Member

@mathetake mathetake commented Jan 12, 2025

Commit Message: ratelimit: per-descriptor hits_addend for route config
Additional Description:

This is a follow up on #37684. Previously, the newly introduced
per-descriptor hits_addend API was only supported by typed_per_filter_config
and its support in the "legacy" core router ratelimit configuration was left TODO.

Since the RateLimitPolicy is coupled with route(r), this impl must be inside
the core, which makes it inappropriate to use formatter in Envoy mobile due to
its use of exceptions. However, even if it didn't have exception uses, it would be
still useless as the mobile cannot use rate limit filter at the end of the day.
So, this patch uses the macro to exclude the entire logic and dependency for
Envoy mobile, which can be relaxed after removing exceptions from formatters.

Risk Level: low
Testing: unit test
Docs Changes: n/a (already done in #37684)
Release Notes: n/a (already done in #37684)
Platform Specific Features: n/a

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #37972 was opened by mathetake.

see: more, trace.

return ret;
}

absl::Status resolveHitsAddendSource(const envoy::config::route::v3::RateLimit::HitsAddend& config,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this and getHitsAddendViaProvider are simply moved from the ratelimit_config.cc below, and their logic hasn't changed

@mathetake mathetake marked this pull request as ready for review January 12, 2025 14:53
@mathetake
Copy link
Copy Markdown
Member Author

/assign @wbpcode

@mathetake
Copy link
Copy Markdown
Member Author

ok formatter having exceptions makes mobile angry

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

so i disable this for envoy mobile build using ENVOY_STATIC_EXTENSION_REGISTRATION - at the end of the day, it's useless on mobile, so it should be good

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

@phlax fyi this will be a blocker for the next v1.33 since otherwise the new API would be half-backed

Comment on lines +434 to +441
] + select({
"//bazel:disable_static_extension_registration": [],
"//conditions:default": [
# See the comments in the header file.
"//source/common/formatter:formatter_extension_lib",
"//source/common/formatter:substitution_formatter_lib",
],
}),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This actually make thing too complex. basically, you only need to link the substitution_formatter_lib here which is exception free.

The main lib will link the formatter_extension_lib as extensions.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Basically, I won't recommend to add new feature to the route's rate_limits because we should use the typed_per_filter_config for filters' configuration.

So, if there is no strong requirement, I will suggest you to use typed_per_filter_config rather than enhancing the route's rate_limits.

@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Jan 13, 2025

/wait

@mathetake
Copy link
Copy Markdown
Member Author

ok, i will take a look at the EG side on how i can mitigate - let's see

@phlax phlax added this to the 1.33.0 milestone Jan 13, 2025
@mathetake
Copy link
Copy Markdown
Member Author

mathetake commented Jan 13, 2025

ok managed to make it work without this change, thank you for the comment @wbpcode

@mathetake mathetake closed this Jan 13, 2025
@mathetake mathetake deleted the hitsaddend branch January 13, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants