Skip to content

Commit

Permalink
Refine UpdateScheduler
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Sep 13, 2023
1 parent c1639cd commit 540500d
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,34 @@ func (c *Cluster) UpdateScheduler() {
s, err := schedulers.CreateScheduler(
scheduler.Type,
c.coordinator.GetOperatorController(),
// NOTICE: currently the scheduler config stored in this storage won't be used,
// we need to figure out a way to unify this storage and persisted config.
c.storage,
schedulers.ConfigSliceDecoder(scheduler.Type, scheduler.Args),
schedulersController.RemoveScheduler,
)
if err != nil {
log.Error("failed to create scheduler",
zap.String("scheduler-type", scheduler.Type),
zap.Strings("scheduler-args", scheduler.Args),
errs.ZapError(err))
continue
}
name := s.GetName()
if existed, _ := schedulersController.IsSchedulerExisted(name); existed {
log.Info("scheduler has already existed, skip adding it",
zap.String("scheduler-name", name),
zap.Strings("scheduler-args", scheduler.Args))
continue
}
if err != nil {
log.Error("failed to create scheduler",
zap.String("scheduler-name", name), zap.Strings("scheduler-args", scheduler.Args), errs.ZapError(err))
}
if err := schedulersController.AddScheduler(s, scheduler.Args...); err != nil {
log.Error("failed to add scheduler",
zap.String("scheduler-name", name), zap.Strings("scheduler-args", scheduler.Args), errs.ZapError(err))
zap.String("scheduler-name", name),
zap.Strings("scheduler-args", scheduler.Args),
errs.ZapError(err))
continue
}
log.Info("add scheduler successfully",
zap.String("scheduler-name", name), zap.Strings("scheduler-args", scheduler.Args))
zap.String("scheduler-name", name),
zap.Strings("scheduler-args", scheduler.Args))
}
// Remove the deleted schedulers.
for _, name := range schedulersController.GetSchedulerNames() {
Expand All @@ -235,9 +243,13 @@ func (c *Cluster) UpdateScheduler() {
continue
}
if err := schedulersController.RemoveScheduler(name); err != nil {
log.Error("failed to remove scheduler", zap.String("scheduler-name", name), errs.ZapError(err))
log.Error("failed to remove scheduler",
zap.String("scheduler-name", name),
errs.ZapError(err))
continue
}
log.Info("remove scheduler successfully", zap.String("scheduler-name", name))
log.Info("remove scheduler successfully",
zap.String("scheduler-name", name))
}
}
}
Expand Down

0 comments on commit 540500d

Please sign in to comment.