Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ratelimit: add dynamic metadata to ratelimit response #14508

Merged
merged 11 commits into from
Jan 7, 2021

Conversation

esmet
Copy link
Contributor

@esmet esmet commented Dec 22, 2020

Supports setting dynamic metdata from ratelimit responses, similar to ext_authz.

Commit Message: ratelimit: add dynamic-metadata to ratelimit response
Additional Description:
Risk Level: Low (new, opt-in functionality to an extension)
Testing: Expanded existing unit tests for network, http, and thrift filters to include a dynamic metadata case
Docs Changes: API protos documented
Release Notes: ratelimit: added :ref:dynamic_metadata <envoy_v3_api_field_service.ratelimit.v3.RateLimitResponse.dynamic_metadata> field to support setting dynamic metadata from the ratelimit service.
Platform Specific Features:
Fixes #14507

Signed-off-by: John Esmet <john.esmet@gmail.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
API shepherd assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #14508 was opened by esmet.

see: more, trace.

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
…n every implementation for consistency.

Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet esmet marked this pull request as ready for review January 4, 2021 22:48
@esmet esmet requested a review from zuercher as a code owner January 4, 2021 22:48
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet
Copy link
Contributor Author

esmet commented Jan 5, 2021

I fixed the docs CI job (in theory) so this should be all ready to review now.

@mattklein123 mattklein123 self-assigned this Jan 5, 2021
Signed-off-by: John Esmet <john.esmet@gmail.com>
Signed-off-by: John Esmet <john.esmet@gmail.com>
@markdroth
Copy link
Contributor

/lgtm api

@repokitteh-read-only repokitteh-read-only bot removed the api label Jan 6, 2021
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM with small comment.

/wait

Comment on lines 108 to 111
// TODO(esmet): This dynamic metadata copy is probably unnecessary, but let's just following the
// existing pattern of copying parameters over as unique pointers for now.
DynamicMetadataPtr dynamic_metadata =
std::make_unique<ProtobufWkt::Struct>(response->dynamic_metadata());
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid allocating here if there is no metadata which will be most cases. Can you guard this with has_dynamic_metadata()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's fair. By doing that, we probably don't even need to optimize away the copy when there is metadata, since the common case is still zero copy/alloc.

So, I'll add the guard and remove the comment.

Signed-off-by: John Esmet <john.esmet@gmail.com>
@esmet esmet changed the title ratelimit: add dynamic-metadata to ratelimit response ratelimit: add dynamic metadata to ratelimit response Jan 6, 2021
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123
Copy link
Member

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Check envoy-presubmit didn't fail.

🐱

Caused by: a #14508 (comment) was created by @mattklein123.

see: more, trace.

@mattklein123 mattklein123 merged commit 89ae3fe into envoyproxy:master Jan 7, 2021
mpuncel added a commit to mpuncel/envoy that referenced this pull request Jan 8, 2021
* master: (48 commits)
  Resolve 14506, avoid libidn2 for our curl dependency (envoyproxy#14601)
  fix new/free mismatch in Mainthread utility (envoyproxy#14596)
  opencensus: deprecate Zipkin configuration. (envoyproxy#14576)
  upstream: clean up code location (envoyproxy#14580)
  configuration impl: add cast for ios compilation (envoyproxy#14590)
  buffer impl: add cast for android compilation (envoyproxy#14589)
  ratelimit: add dynamic metadata to ratelimit response (envoyproxy#14508)
  tcp_proxy: wait for CONNECT response before start streaming data (envoyproxy#14317)
  stream info: cleanup address handling (envoyproxy#14432)
  [deps] update upb to latest commit (envoyproxy#14582)
  Add utility to check whether the execution is in main thread. (envoyproxy#14457)
  listener: undeprecate bind_to_port (envoyproxy#14480)
  Fix data race in overload integration test (envoyproxy#14586)
  deps: update PGV (envoyproxy#14571)
  dependencies: update cve_scan.py for some libcurl 7.74.0 false positives. (envoyproxy#14572)
  Network::Connection: Add L4 crash dumping support (envoyproxy#14509)
  ssl: remember stat names for configured ciphers. (envoyproxy#14534)
  formatter: add custom date formatting to downstream cert start and end dates (envoyproxy#14502)
  feat(lua): allow setting response body when the upstream response body is empty (envoyproxy#14486)
  Generalize the gRPC access logger base classes (envoyproxy#14469)
  ...

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
@esmet esmet deleted the ratelimit-metadata branch January 11, 2021 15:52
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.

Support setting dynamic metadata from external ratelimit service
3 participants