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

server: add gRPC rate limit #6834

Merged
merged 7 commits into from
Aug 24, 2023
Merged

server: add gRPC rate limit #6834

merged 7 commits into from
Aug 24, 2023

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jul 24, 2023

What problem does this PR solve?

Issue Number: ref #6556. close #5739.

What is changed and how does it work?

This PR adds a gRPC rate limit for some interfaces to prevent wasting lots of resources.

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jul 24, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • nolouch

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jul 24, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Jul 24, 2023
@ti-chi-bot ti-chi-bot bot requested review from disksing and HunDunDM July 24, 2023 10:52
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 24, 2023
@rleungx rleungx marked this pull request as ready for review July 25, 2023 08:00
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 25, 2023
@rleungx rleungx requested review from nolouch and CabinfeverB and removed request for disksing and HunDunDM July 25, 2023 08:02
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #6834 (6696c12) into master (ebceb83) will decrease coverage by 0.01%.
Report is 1 commits behind head on master.
The diff coverage is 53.68%.

❗ Current head 6696c12 differs from pull request most recent head 77a9848. Consider uploading reports for the commit 77a9848 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6834      +/-   ##
==========================================
- Coverage   74.23%   74.23%   -0.01%     
==========================================
  Files         433      427       -6     
  Lines       45860    45508     -352     
==========================================
- Hits        34046    33784     -262     
+ Misses       8802     8741      -61     
+ Partials     3012     2983      -29     
Flag Coverage Δ
unittests 74.23% <53.68%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

errors.toml Outdated Show resolved Hide resolved
defer limiter.Release(fName)
} else {
return &pdpb.GetStoreResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we need to define an error type that can let the client to handle it.

@@ -848,6 +871,17 @@ func (s *GrpcServer) PutStore(ctx context.Context, request *pdpb.PutStoreRequest

// GetAllStores implements gRPC PDServer.
func (s *GrpcServer) GetAllStores(ctx context.Context, request *pdpb.GetAllStoresRequest) (*pdpb.GetAllStoresResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

How abou renaming GetStores to GetAllStores in http-api's router.go?

@@ -299,8 +305,8 @@ func CreateServer(ctx context.Context, cfg *config.Config, services []string, le
diagnosticspb.RegisterDiagnosticsServer(gs, s)
// Register the micro services GRPC service.
s.registry.InstallAllGRPCServices(s, gs)
s.grpcServer = gs
Copy link
Member

Choose a reason for hiding this comment

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

When exec initGRPCServiceLabels, will it fetch the methods of ETCD gRPC server?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we only have one gRPC server.

@ti-chi-bot ti-chi-bot bot added status/LGT1 Indicates that a PR has LGTM 1. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 2, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 4, 2023

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 8, 2023
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 21, 2023
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
@nolouch nolouch removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2023
@nolouch
Copy link
Contributor

nolouch commented Aug 23, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 23, 2023

@nolouch: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 23, 2023

This pull request has been accepted and is ready to merge.

Commit hash: 9b6440a

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 23, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 23, 2023

@rleungx: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit fbd386a into tikv:master Aug 24, 2023
19 checks passed
@rleungx rleungx deleted the grpc-rate-limit branch August 24, 2023 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide PD self-protection for gRPC requests
3 participants