Skip to content

Commit

Permalink
Merge pull request #504 from sivanzcw/modified
Browse files Browse the repository at this point in the history
Dynamic loading comfigmap about action and plugins of scheduler, move loadSchedulerConf processing from run to runOnce
  • Loading branch information
volcano-sh-bot committed Nov 1, 2019
2 parents 20b0327 + 1909fd7 commit 5f271fa
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,10 @@ func NewScheduler(

// Run runs the Scheduler
func (pc *Scheduler) Run(stopCh <-chan struct{}) {
var err error

// Start cache for policy.
go pc.cache.Run(stopCh)
pc.cache.WaitForCacheSync(stopCh)

// Load configuration of scheduler
schedConf := defaultSchedulerConf
if len(pc.schedulerConf) != 0 {
if schedConf, err = readSchedulerConf(pc.schedulerConf); err != nil {
glog.Errorf("Failed to read scheduler configuration '%s', using default configuration: %v",
pc.schedulerConf, err)
schedConf = defaultSchedulerConf
}
}

pc.actions, pc.plugins, err = loadSchedulerConf(schedConf)
if err != nil {
panic(err)
}

go wait.Until(pc.runOnce, pc.schedulePeriod, stopCh)
}

Expand All @@ -91,6 +74,8 @@ func (pc *Scheduler) runOnce() {
defer glog.V(4).Infof("End scheduling ...")
defer metrics.UpdateE2eDuration(metrics.Duration(scheduleStartTime))

pc.loadSchedulerConf()

ssn := framework.OpenSession(pc.cache, pc.plugins)
defer framework.CloseSession(ssn)

Expand All @@ -100,3 +85,22 @@ func (pc *Scheduler) runOnce() {
metrics.UpdateActionDuration(action.Name(), metrics.Duration(actionStartTime))
}
}

func (pc *Scheduler) loadSchedulerConf() {
var err error

// Load configuration of scheduler
schedConf := defaultSchedulerConf
if len(pc.schedulerConf) != 0 {
if schedConf, err = readSchedulerConf(pc.schedulerConf); err != nil {
glog.Errorf("Failed to read scheduler configuration '%s', using default configuration: %v",
pc.schedulerConf, err)
schedConf = defaultSchedulerConf
}
}

pc.actions, pc.plugins, err = loadSchedulerConf(schedConf)
if err != nil {
panic(err)
}
}

0 comments on commit 5f271fa

Please sign in to comment.