-
Notifications
You must be signed in to change notification settings - Fork 720
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
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
server/api/config.go
Outdated
@@ -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": |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
There was a problem hiding this 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/
server/api/router.go
Outdated
@@ -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")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET")) | |
registerFunc(apiRouter, "/self-protection/config", selfProtectionHandler.GetSelfProtectionConfig, setMethods("GET")) |
server/api/router.go
Outdated
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registerFunc(apiRouter, "/self_protection/config", selfProtectionHandler.SetSelfProtectionConfig, setMethods("POST"), setAuditBackend(localLog)) | |
registerFunc(apiRouter, "/self-protection/config", selfProtectionHandler.SetSelfProtectionConfig, setMethods("POST"), setAuditBackend(localLog)) |
server/api/router.go
Outdated
@@ -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")) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update
There was a problem hiding this 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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", | ||
} |
There was a problem hiding this comment.
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{}{}
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
@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. |
This pull request has been accepted and is ready to merge. Commit hash: 083b857
|
@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. |
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
Check List
Tests
Code changes
Release note