Skip to content

Commit

Permalink
Bugfix when starting the cluster with raft-kv2
Browse files Browse the repository at this point in the history
Signed-off-by: lucasliang <[email protected]>
  • Loading branch information
LykxSassinator committed Aug 23, 2023
1 parent 65e7c26 commit e83599c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,6 @@ func (c *Coordinator) initSchedulers() {
if err != nil {
log.Fatal("cannot load schedulers' config", errs.ZapError(err))
}

// If the cluster was set up with `raft-kv2` engine, this cluster should
// open `evict-slow-trend` scheduler as default.
if c.GetCluster().GetStoreConfig().IsRaftKV2() {
scheduleNames = append(scheduleNames, schedulers.EvictSlowTrendType)
configs = append(configs, "")
}

scheduleCfg := c.cluster.GetSchedulerConfig().GetScheduleConfig().Clone()
// The new way to create scheduler with the independent configuration.
for i, name := range scheduleNames {
Expand Down Expand Up @@ -446,6 +438,20 @@ func (c *Coordinator) initSchedulers() {
if err := c.cluster.GetSchedulerConfig().Persist(c.cluster.GetStorage()); err != nil {
log.Error("cannot persist schedule config", errs.ZapError(err))
}

// If the cluster was set up with `raft-kv2` engine, this cluster should
// enable `evict-slow-trend` scheduler as default.
if c.GetCluster().GetStoreConfig().IsRaftKV2() {
name := schedulers.EvictSlowTrendType
args := []string{}

s, err := schedulers.CreateScheduler(name, c.opController, c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(name, args), c.schedulers.RemoveScheduler)
if err != nil {
log.Warn("initializing evict-slow-trend scheduler failed", errs.ZapError(err))
} else if err = c.schedulers.AddScheduler(s, args...); err != nil {
log.Error("can not add scheduler", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", args), errs.ZapError(err))
}
}
}

// LoadPlugin load user plugin
Expand Down

0 comments on commit e83599c

Please sign in to comment.