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

config, api: Add Service Config #4869

Merged
merged 14 commits into from
May 17, 2022
Merged

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Apr 28, 2022

Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com

What problem does this PR solve?

Issue Number: Ref #4480

What is changed and how does it work?

Add an independent config for audit and rate limit in the future

add service config

Check List

Tests

  • Unit test
  • Integration test

Code changes

Release note

None.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 28, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • AndreMouche
  • rleungx

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 ti-chi-bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Apr 28, 2022
@CabinfeverB CabinfeverB changed the title add service config config, api: Add Service Config Apr 28, 2022
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Apr 28, 2022
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@CabinfeverB CabinfeverB marked this pull request as ready for review April 28, 2022 06:32
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 28, 2022
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #4869 (7eadaf8) into master (3e95051) will increase coverage by 0.02%.
The diff coverage is 81.57%.

@@            Coverage Diff             @@
##           master    #4869      +/-   ##
==========================================
+ Coverage   75.37%   75.39%   +0.02%     
==========================================
  Files         298      302       +4     
  Lines       29554    29657     +103     
==========================================
+ Hits        22275    22360      +85     
- Misses       5334     5353      +19     
+ Partials     1945     1944       -1     
Flag Coverage Δ
unittests 75.39% <81.57%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
server/api/min_resolved_ts.go 100.00% <ø> (ø)
server/api/service_gc_safepoint.go 60.86% <ø> (ø)
server/config/config.go 78.08% <ø> (-0.10%) ⬇️
server/config/persist_options.go 93.72% <ø> (+0.71%) ⬆️
server/storage/endpoint/key_path.go 100.00% <ø> (ø)
server/storage/storage.go 70.27% <ø> (ø)
server/storage/endpoint/service_middleware.go 63.63% <63.63%> (ø)
server/api/service_middleware.go 68.18% <68.18%> (ø)
server/config/service_middleware_config.go 75.00% <75.00%> (ø)
server/server.go 72.81% <96.42%> (-0.01%) ⬇️
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e95051...7eadaf8. Read the comment docs.

@@ -151,6 +151,8 @@ func (h *confHandler) updateConfig(cfg *config.Config, key string, value interfa
return errors.Errorf("cannot update config prefix %s", kp[0])
}
return h.updateReplicationModeConfig(cfg, kp[1:], value)
case "service":
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a better naming?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a better naming?

how about "self-protection"

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 29, 2022
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2022
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Copy link
Member

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

Could you please use hyphens (-) to improve the readability of URIs ? ref https://restfulapi.net/resource-naming/

@@ -282,6 +282,10 @@ func createRouter(prefix string, svr *server.Server) *mux.Router {
registerFunc(apiRouter, "/admin/persist-file/{file_name}", adminHandler.SavePersistFile, setMethods("POST"), setAuditBackend(localLog))
registerFunc(clusterRouter, "/admin/replication_mode/wait-async", adminHandler.UpdateWaitAsyncTime, setMethods("POST"), setAuditBackend(localLog))

selfProtectionHandler := newSelfProtectionHandler(svr, rd)
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET"))
registerFunc(apiRouter, "/self-protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET"))

@@ -282,6 +282,10 @@ func createRouter(prefix string, svr *server.Server) *mux.Router {
registerFunc(apiRouter, "/admin/persist-file/{file_name}", adminHandler.SavePersistFile, setMethods("POST"), setAuditBackend(localLog))
registerFunc(clusterRouter, "/admin/replication_mode/wait-async", adminHandler.UpdateWaitAsyncTime, setMethods("POST"), setAuditBackend(localLog))

selfProtectionHandler := newSelfProtectionHandler(svr, rd)
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET"))
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.SetSelfProtectionConfig, setMethods("POST"), setAuditBackend(localLog))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.SetSelfProtectionConfig, setMethods("POST"), setAuditBackend(localLog))
registerFunc(apiRouter, "/self-protection/config", selfProtectionHandler.SetSelfProtectionConfig, setMethods("POST"), setAuditBackend(localLog))

@@ -282,6 +282,10 @@ func createRouter(prefix string, svr *server.Server) *mux.Router {
registerFunc(apiRouter, "/admin/persist-file/{file_name}", adminHandler.SavePersistFile, setMethods("POST"), setAuditBackend(localLog))
registerFunc(clusterRouter, "/admin/replication_mode/wait-async", adminHandler.UpdateWaitAsyncTime, setMethods("POST"), setAuditBackend(localLog))

selfProtectionHandler := newSelfProtectionHandler(svr, rd)
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change self_protection to service-middlewares or middlewares? IMO, self-protection is better to be the project name, not in the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

update

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
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.

Overall LGTM. cc @rleungx

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

The rest LGTM

}
}

// @Tags service_middleware
Copy link
Member

Choose a reason for hiding this comment

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

better to keep the style with other interfaces

Copy link
Member Author

Choose a reason for hiding this comment

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

better to keep the style with other interfaces

How about changing all interfaces to Snake case? I have changed service_gc_safepoint and min_resolved_ts

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 12, 2022
Copy link
Member

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

Rest LGTM

return
}

for k, v := range conf {
Copy link
Member

Choose a reason for hiding this comment

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

what if the conf is empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

add a check

addr := fmt.Sprintf("%s/service-middleware/config", s.urlPrefix)
ms := map[string]interface{}{
"enable-audit": "true",
}
Copy link
Member

Choose a reason for hiding this comment

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

How about add a case with an empty body or ms := map[string]interface{}{}

Copy link
Member Author

Choose a reason for hiding this comment

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

update

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Copy link
Member

@AndreMouche AndreMouche 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 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 13, 2022
@CabinfeverB CabinfeverB requested a review from nolouch May 17, 2022 08:41
@rleungx
Copy link
Member

rleungx commented May 17, 2022

/merge

@ti-chi-bot
Copy link
Member

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

/run-all-tests

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
Member

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

Commit hash: 083b857

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 17, 2022
@ti-chi-bot
Copy link
Member

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

At the same time I will also trigger all tests for you:

/run-all-tests

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 merged commit dac3836 into tikv:master May 17, 2022
ti-chi-bot added a commit that referenced this pull request Jun 13, 2022
ref #4666, ref #4839, ref #4869

update limiter config when reload presist config

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
CabinfeverB added a commit to CabinfeverB/pd that referenced this pull request Jul 14, 2022
ref tikv#4666, ref tikv#4839, ref tikv#4869

update limiter config when reload presist config

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
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. 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.

5 participants