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

Dynamic loading comfigmap about action and plugins of scheduler, move loadSchedulerConf processing from run to runOnce #504

Merged
merged 1 commit into from
Nov 1, 2019
Merged
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
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better performance, we can add a file watcher


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)
}
}