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: fix the default config output of shuffle region scheduler #2416

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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