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

api: change store limit by label #2697

Merged
merged 15 commits into from
Sep 10, 2020
Merged

api: change store limit by label #2697

merged 15 commits into from
Sep 10, 2020

Conversation

ZenoTan
Copy link
Contributor

@ZenoTan ZenoTan commented Jul 29, 2020

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

  • Unit test
  • Integration test

Code changes

  • Has HTTP API interfaces change
  • Has pd-ctl interfaces change

Side effects

Related changes

Release note

@ti-srebot ti-srebot added the contribution This PR is from a community contributor. label Jul 29, 2020
@ZenoTan
Copy link
Contributor Author

ZenoTan commented Jul 29, 2020

/run-all-tests

@nolouch nolouch requested review from rleungx and nolouch July 29, 2020 14:32
@@ -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>]",
Copy link
Member

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?

Copy link
Contributor Author

@ZenoTan ZenoTan Jul 31, 2020

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/api/store.go Outdated Show resolved Hide resolved
// 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"`
Copy link
Contributor

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.

Copy link
Contributor Author

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)

Copy link
Contributor

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

Copy link
Contributor Author

@ZenoTan ZenoTan Aug 5, 2020

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?

tests/pdctl/store/store_test.go Outdated Show resolved Hide resolved
@@ -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")
Copy link
Contributor

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.

Copy link
Member

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

// 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"`
Copy link
Contributor

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

valid bool
}

func (sr *LabelStoreRule) parse(s string) {
Copy link
Member

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?

@rleungx
Copy link
Member

rleungx commented Aug 25, 2020

I think we can use the original command to set the store limit but provide an option to use the label. e.g. store limit add-peer 5 [<key> <value>, ...]. And for this label, we can filter the stores and directly set the specified value to the store which meeting the label requirement.

@nolouch
Copy link
Contributor

nolouch commented Sep 1, 2020

Can we accelerate this PR? @ZenoTan

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 3, 2020

Sure. Next week I'll work on this.

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 7, 2020

Will open soon.

Signed-off-by: ZenoTan <zenotan1998@gmail.com>
@ZenoTan ZenoTan reopened this Sep 7, 2020
server/cluster/cluster.go Outdated Show resolved Hide resolved
ZenoTan and others added 6 commits September 8, 2020 11:55
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>
Signed-off-by: ZenoTan <zenotan1998@gmail.com>
tools/pd-ctl/pdctl/command/store_command.go Show resolved Hide resolved
@@ -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"}
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 add a simpler command for TiFlash? cc @rleungx

Copy link
Contributor Author

@ZenoTan ZenoTan Sep 9, 2020

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?

Copy link
Contributor

@nolouch nolouch Sep 9, 2020

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.

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-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 9, 2020
cmd.Println("Labels are an option of set all stores limit.")
} else {
postInput := map[string]interface{}{}
prefix := path.Join(storesPrefix, "limit")
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 using a constant?

// 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))
Copy link
Member

Choose a reason for hiding this comment

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

remove it?

ZenoTan and others added 3 commits September 10, 2020 10:34
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>
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.

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Sep 10, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 10, 2020
@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/merge

@ti-srebot
Copy link
Contributor

@ZenoTan Oops! auto merge is restricted to Committers of the SIG.See the corresponding SIG page for more information. Related SIG: scheduling(slack).

@nolouch
Copy link
Contributor

nolouch commented Sep 10, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 10, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@ZenoTan merge failed.

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/run-all-tests

2 similar comments
@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/run-all-tests

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/run-all-tests

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/run-test

@ZenoTan
Copy link
Contributor Author

ZenoTan commented Sep 10, 2020

/run-integration-lightning-test

@nolouch
Copy link
Contributor

nolouch commented Sep 10, 2020

/test

@nolouch
Copy link
Contributor

nolouch commented Sep 10, 2020

/rebuild

@nolouch
Copy link
Contributor

nolouch commented Sep 10, 2020

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 62934dc into tikv:master Sep 10, 2020
@rleungx rleungx changed the title Change store limit by label api: change store limit by label Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. 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.

4 participants