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

pdctl: support config balance-leader #4656

Merged
merged 39 commits into from
Mar 16, 2022

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Feb 18, 2022

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

What problem does this PR solve?

Issue Number: ref #4610
This PR should be merged after #4652 #4655

What is changed and how it works?

pdctl supports update balance-leader-scheduler config

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

Related changes

Release note

pdctl supports update balance-leader-scheduler config.

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

ti-chi-bot commented Feb 18, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bufferflies
  • 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/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 Feb 18, 2022
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #4656 (393b884) into master (7e26092) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4656      +/-   ##
==========================================
- Coverage   75.09%   75.03%   -0.06%     
==========================================
  Files         284      284              
  Lines       28022    28038      +16     
==========================================
- Hits        21043    21039       -4     
- Misses       5113     5129      +16     
- Partials     1866     1870       +4     
Flag Coverage Δ
unittests 75.03% <100.00%> (-0.06%) ⬇️

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

Impacted Files Coverage Δ
server/schedulers/balance_leader.go 92.30% <100.00%> (+0.12%) ⬆️
tools/pd-ctl/pdctl/command/scheduler.go 75.37% <100.00%> (+0.76%) ⬆️
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
server/tso/local_allocator.go 64.86% <0.00%> (-13.52%) ⬇️
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
server/election/leadership.go 75.25% <0.00%> (-2.07%) ⬇️
server/tso/allocator_manager.go 61.85% <0.00%> (-1.97%) ⬇️
server/member/member.go 65.24% <0.00%> (-1.61%) ⬇️
server/server.go 73.94% <0.00%> (-1.42%) ⬇️
server/schedule/operator_controller.go 84.44% <0.00%> (-0.81%) ⬇️
... and 9 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 7e26092...393b884. Read the comment docs.

@@ -442,10 +442,31 @@ func NewConfigSchedulerCommand() *cobra.Command {
newConfigHotRegionCommand(),
newConfigShuffleRegionCommand(),
newConfigGrantHotRegionCommand(),
newConfigBalanceLeaderCommand(),
Copy link
Contributor

Choose a reason for hiding this comment

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

How about other scheduler.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about other scheduler.

other schedulers should modify their config handler firstly

)
return c
}

func newConfigBalanceLeaderCommand() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is similar with newConfigHotRegionCommand, maybe exract same code.

Copy link
Member Author

@CabinfeverB CabinfeverB Feb 18, 2022

Choose a reason for hiding this comment

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

The function is similar with newConfigHotRegionCommand, maybe exract same code.

maybe I can abstract out a function for all schedulers

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, each scheduler has a different config API. It is possible to refactor it in the future, so I think just implement it simply now.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Ranges []core.KeyRange `json:"ranges"`
Batch int `json:"batch"`
}

Copy link
Contributor

Choose a reason for hiding this comment

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

add some annotation.

}

func (handler *balanceLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.Request) {
data, _ := io.ReadAll(r.Body)
Copy link
Contributor

Choose a reason for hiding this comment

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

why ignor this error.

Copy link
Member Author

@CabinfeverB CabinfeverB Mar 15, 2022

Choose a reason for hiding this comment

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

http.Request.Body only has EOF error. if EOF , it means data is nil, and it will be handled in line 97

Copy link
Contributor

@bufferflies bufferflies 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

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

c.AddCommand(&cobra.Command{
Use: "show",
Short: "list the config item",
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
Short: "list the config item",
Short: "show the config item",

@@ -213,26 +213,37 @@ func NewAccessPath(path, method string) AccessPath {
return AccessPath{Path: path, Method: method}
}

type CheckOption func([]byte, int)
Copy link
Contributor

@bufferflies bufferflies Mar 15, 2022

Choose a reason for hiding this comment

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

where is it used?

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@@ -113,12 +116,13 @@ func (conf *balanceLeaderSchedulerConfig) Update(data []byte) (int, interface{})
return http.StatusBadRequest, "config item not found"
}

func (conf *balanceLeaderSchedulerConfig) Adjust() {
func (conf *balanceLeaderSchedulerConfig) Validate() bool {
if conf.Batch < 1 {
Copy link
Member

Choose a reason for hiding this comment

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

use ||

@@ -113,12 +116,13 @@ func (conf *balanceLeaderSchedulerConfig) Update(data []byte) (int, interface{})
return http.StatusBadRequest, "config item not found"
}

func (conf *balanceLeaderSchedulerConfig) Adjust() {
func (conf *balanceLeaderSchedulerConfig) Validate() bool {
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
func (conf *balanceLeaderSchedulerConfig) Validate() bool {
func (conf *balanceLeaderSchedulerConfig) validate() bool {

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

@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 Mar 16, 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>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@rleungx
Copy link
Member

rleungx commented Mar 16, 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: 4c08c71

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 16, 2022
@ti-chi-bot ti-chi-bot merged commit 1a353ae into tikv:master Mar 16, 2022
rleungx pushed a commit to rleungx/pd that referenced this pull request Mar 17, 2022
ref tikv#4610, ref tikv#4652, ref tikv#4655

pdctl supports update balance-leader-scheduler config

Signed-off-by: Cabinfever_B <cabinfeveroier@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 Denotes a PR that will be considered when it comes time to generate release notes. 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