Skip to content

Commit

Permalink
pdctl: fix the default config output of shuffle region scheduler (#2416)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored May 13, 2020
1 parent 0e3d218 commit 8d56174
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions tests/pdctl/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ func (s *schedulerTestSuite) TestScheduler(c *C) {
mustExec([]string{"-u", pdAddr, "scheduler", "config", "shuffle-region-scheduler", "set-roles", "learner"}, nil)
mustExec([]string{"-u", pdAddr, "scheduler", "config", "shuffle-region-scheduler", "show-roles"}, &roles)
c.Assert(roles, DeepEquals, []string{"learner"})
mustExec([]string{"-u", pdAddr, "scheduler", "config", "shuffle-region-scheduler"}, &roles)
c.Assert(roles, DeepEquals, []string{"learner"})

// test echo
echo := pdctl.GetEcho([]string{"-u", pdAddr, "scheduler", "add", "balance-region-scheduler"})
Expand Down
15 changes: 10 additions & 5 deletions tools/pd-ctl/pdctl/command/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func NewConfigSchedulerCommand() *cobra.Command {
func newConfigHotRegionCommand() *cobra.Command {
c := &cobra.Command{
Use: "balance-hot-region-scheduler",
Short: "show evict-leader-scheduler config",
Short: "evict-leader-scheduler config",
Run: listSchedulerConfigCommandFunc,
}
c.AddCommand(&cobra.Command{
Expand All @@ -456,7 +456,7 @@ func newConfigHotRegionCommand() *cobra.Command {
func newConfigEvictLeaderCommand() *cobra.Command {
c := &cobra.Command{
Use: "evict-leader-scheduler",
Short: "show evict-leader-scheduler config",
Short: "evict-leader-scheduler config",
Run: listSchedulerConfigCommandFunc,
}
c.AddCommand(&cobra.Command{
Expand All @@ -474,7 +474,7 @@ func newConfigEvictLeaderCommand() *cobra.Command {
func newConfigGrantLeaderCommand() *cobra.Command {
c := &cobra.Command{
Use: "grant-leader-scheduler",
Short: "show grant-leader-scheduler config",
Short: "grant-leader-scheduler config",
Run: listSchedulerConfigCommandFunc,
}
c.AddCommand(&cobra.Command{
Expand All @@ -493,10 +493,11 @@ func newConfigShuffleRegionCommand() *cobra.Command {
c := &cobra.Command{
Use: "shuffle-region-scheduler",
Short: "shuffle-region-scheduler config",
Run: showShuffleRegionSchedulerRolesCommandFunc,
}
c.AddCommand(&cobra.Command{
Use: "show-roles",
Short: "show affected roles (leader,follower,learner)",
Short: "show affected roles (leader, follower, learner)",
Run: showShuffleRegionSchedulerRolesCommandFunc,
}, &cobra.Command{
Use: "set-roles [leader,][follower,][learner]",
Expand Down Expand Up @@ -594,7 +595,11 @@ func showShuffleRegionSchedulerRolesCommandFunc(cmd *cobra.Command, args []strin
cmd.Println(cmd.UsageString())
return
}
path := path.Join(schedulerConfigPrefix, cmd.Parent().Name(), "roles")
p := cmd.Name()
if p == "show-roles" {
p = cmd.Parent().Name()
}
path := path.Join(schedulerConfigPrefix, p, "roles")
r, err := doRequest(cmd, path, http.MethodGet)
if err != nil {
cmd.Println(err)
Expand Down

0 comments on commit 8d56174

Please sign in to comment.