Skip to content

Commit

Permalink
scheduler: use right check for evict/grant leader scheduler (#8758) (#…
Browse files Browse the repository at this point in the history
…8779)

ref #8756

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: okJiang <[email protected]>

Co-authored-by: okJiang <[email protected]>
  • Loading branch information
ti-chi-bot and okJiang authored Nov 7, 2024
1 parent 4b29e0d commit f235847
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (conf *evictLeaderSchedulerConfig) getStores() []uint64 {
}

func (conf *evictLeaderSchedulerConfig) BuildWithArgs(args []string) error {
if len(args) != 1 {
if len(args) < 1 {
return errs.ErrSchedulerConfig.FastGenByArgs("id")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/grant_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type grantLeaderSchedulerConfig struct {
}

func (conf *grantLeaderSchedulerConfig) BuildWithArgs(args []string) error {
if len(args) != 1 {
if len(args) < 1 {
return errs.ErrSchedulerConfig.FastGenByArgs("id")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/schedulers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func schedulersRegister() {
// evict leader
RegisterSliceDecoderBuilder(EvictLeaderType, func(args []string) ConfigDecoder {
return func(v any) error {
if len(args) != 1 {
if len(args) < 1 {
return errs.ErrSchedulerConfig.FastGenByArgs("id")
}
conf, ok := v.(*evictLeaderSchedulerConfig)
Expand Down Expand Up @@ -237,7 +237,7 @@ func schedulersRegister() {
// grant leader
RegisterSliceDecoderBuilder(GrantLeaderType, func(args []string) ConfigDecoder {
return func(v any) error {
if len(args) != 1 {
if len(args) < 1 {
return errs.ErrSchedulerConfig.FastGenByArgs("id")
}

Expand Down
4 changes: 2 additions & 2 deletions plugin/scheduler_example/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
func init() {
schedulers.RegisterSliceDecoderBuilder(EvictLeaderType, func(args []string) schedulers.ConfigDecoder {
return func(v any) error {
if len(args) != 1 {
if len(args) < 1 {
return errors.New("should specify the store-id")
}
conf, ok := v.(*evictLeaderSchedulerConfig)
Expand Down Expand Up @@ -99,7 +99,7 @@ type evictLeaderSchedulerConfig struct {
}

func (conf *evictLeaderSchedulerConfig) BuildWithArgs(args []string) error {
if len(args) != 1 {
if len(args) < 1 {
return errors.New("should specify the store-id")
}

Expand Down

0 comments on commit f235847

Please sign in to comment.