-
Notifications
You must be signed in to change notification settings - Fork 719
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
api: change store limit by label #2697
Conversation
/run-all-tests |
@@ -89,7 +89,7 @@ func NewSetStoreWeightCommand() *cobra.Command { | |||
// NewStoreLimitCommand returns a limit subcommand of storeCmd. | |||
func NewStoreLimitCommand() *cobra.Command { | |||
c := &cobra.Command{ | |||
Use: "limit [<type>]|[<store_id>|<all> <limit> <type>]", | |||
Use: "limit [<type>]|[<store_id>|<all>|<rule> <limit> <type>]", |
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 make the rule as an option?
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.
You mean store limit (rule) (limit) (type)
?
server/config/config.go
Outdated
// StoreRuleList is the history of store rules. | ||
StoreRuleList StoreRules `toml:"store-rule-list" json:"store-rule-list"` | ||
// StoreRuleLimit is the limit of scheduling for store rules. | ||
StoreRuleLimit map[string]StoreLimitConfig `toml:"store-rule-limit" json:"store-rule-limit"` |
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 do we distinguish StoreRuleLimit
and StoreLimit
? I think it is a bit complicated.
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.
Yes. If it is not exposed to users, then where to save the map(which is used when a new store comes)
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.
Yes,we can hide him and provide a separate API for the query. 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.
Provide something like InternalConfig
, which can be used in other scenarios like this. Some additional logic will be added to show config
. Is it a good solution?
server/api/router.go
Outdated
@@ -110,6 +110,8 @@ func createRouter(ctx context.Context, prefix string, svr *server.Server) *mux.R | |||
clusterRouter.HandleFunc("/stores/remove-tombstone", storesHandler.RemoveTombStone).Methods("DELETE") | |||
clusterRouter.HandleFunc("/stores/limit", storesHandler.GetAllLimit).Methods("GET") | |||
clusterRouter.HandleFunc("/stores/limit", storesHandler.SetAllLimit).Methods("POST") | |||
clusterRouter.HandleFunc("/stores/rule/limit", storesHandler.GetRuleLimit).Methods("GET") | |||
clusterRouter.HandleFunc("/stores/rule/limit", storesHandler.SetRuleLimit).Methods("POST") |
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.
I more likely change rule
to group
? how do you think? We already have a placement rule, this Rule
may confuse users.
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.
Actually, I prefer not to add a new API. we can make the rules as a parameter or option
server/config/config.go
Outdated
// StoreRuleList is the history of store rules. | ||
StoreRuleList StoreRules `toml:"store-rule-list" json:"store-rule-list"` | ||
// StoreRuleLimit is the limit of scheduling for store rules. | ||
StoreRuleLimit map[string]StoreLimitConfig `toml:"store-rule-limit" json:"store-rule-limit"` |
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.
Yes,we can hide him and provide a separate API for the query. cc @rleungx
server/config/config.go
Outdated
valid bool | ||
} | ||
|
||
func (sr *LabelStoreRule) parse(s string) { |
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 use a way like the store label API to parse the label?
I think we can use the original command to set the store limit but provide an option to use the label. e.g. |
Can we accelerate this PR? @ZenoTan |
Sure. Next week I'll work on this. |
Will open soon. |
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
@@ -196,6 +196,14 @@ func (s *storeTestSuite) TestStore(c *C) { | |||
limit2 = leaderServer.GetRaftCluster().GetStoreLimitByType(2, storelimit.RemovePeer) | |||
c.Assert(limit2, Equals, float64(25)) | |||
|
|||
// store limit all <key> <value> <rate> <type> | |||
args = []string{"-u", pdAddr, "store", "limit", "all", "zone", "uk", "20", "remove-peer"} |
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 add a simpler command for TiFlash? 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.
Maybe store tiflash add-peer 60
?
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.
we can do it in another PR.
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
cmd.Println("Labels are an option of set all stores limit.") | ||
} else { | ||
postInput := map[string]interface{}{} | ||
prefix := path.Join(storesPrefix, "limit") |
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 using a constant?
tests/pdctl/store/store_test.go
Outdated
// store limit all <key> <value> <rate> <type> | ||
args = []string{"-u", pdAddr, "store", "limit", "all", "zone", "uk", "20", "remove-peer"} | ||
_, output, err = pdctl.ExecuteCommandC(cmd, args...) | ||
c.Log(string(output)) |
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.
remove it?
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
Signed-off-by: ZenoTan <zenotan1998@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 |
@ZenoTan Oops! auto merge is restricted to Committers of the SIG.See the corresponding SIG page for more information. Related SIG: scheduling(slack). |
/merge |
/run-all-tests |
@ZenoTan merge failed. |
/run-all-tests |
2 similar comments
/run-all-tests |
/run-all-tests |
/run-test |
/run-integration-lightning-test |
/test |
/rebuild |
/merge |
/run-all-tests |
What problem does this PR solve?
Solve issue #2568
ref: #2504
What is changed and how it works?
Support change store limit according to label. Label is treated as a special store rule here.
Command line like "store limit ... " can be used to change it.
Check List
Tests
Code changes
Side effects
Related changes
Release note