Skip to content

Commit 5f271fa

Browse files
Merge pull request #504 from sivanzcw/modified
Dynamic loading comfigmap about action and plugins of scheduler, move loadSchedulerConf processing from run to runOnce
2 parents 20b0327 + 1909fd7 commit 5f271fa

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

pkg/scheduler/scheduler.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,10 @@ func NewScheduler(
6161

6262
// Run runs the Scheduler
6363
func (pc *Scheduler) Run(stopCh <-chan struct{}) {
64-
var err error
65-
6664
// Start cache for policy.
6765
go pc.cache.Run(stopCh)
6866
pc.cache.WaitForCacheSync(stopCh)
6967

70-
// Load configuration of scheduler
71-
schedConf := defaultSchedulerConf
72-
if len(pc.schedulerConf) != 0 {
73-
if schedConf, err = readSchedulerConf(pc.schedulerConf); err != nil {
74-
glog.Errorf("Failed to read scheduler configuration '%s', using default configuration: %v",
75-
pc.schedulerConf, err)
76-
schedConf = defaultSchedulerConf
77-
}
78-
}
79-
80-
pc.actions, pc.plugins, err = loadSchedulerConf(schedConf)
81-
if err != nil {
82-
panic(err)
83-
}
84-
8568
go wait.Until(pc.runOnce, pc.schedulePeriod, stopCh)
8669
}
8770

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

77+
pc.loadSchedulerConf()
78+
9479
ssn := framework.OpenSession(pc.cache, pc.plugins)
9580
defer framework.CloseSession(ssn)
9681

@@ -100,3 +85,22 @@ func (pc *Scheduler) runOnce() {
10085
metrics.UpdateActionDuration(action.Name(), metrics.Duration(actionStartTime))
10186
}
10287
}
88+
89+
func (pc *Scheduler) loadSchedulerConf() {
90+
var err error
91+
92+
// Load configuration of scheduler
93+
schedConf := defaultSchedulerConf
94+
if len(pc.schedulerConf) != 0 {
95+
if schedConf, err = readSchedulerConf(pc.schedulerConf); err != nil {
96+
glog.Errorf("Failed to read scheduler configuration '%s', using default configuration: %v",
97+
pc.schedulerConf, err)
98+
schedConf = defaultSchedulerConf
99+
}
100+
}
101+
102+
pc.actions, pc.plugins, err = loadSchedulerConf(schedConf)
103+
if err != nil {
104+
panic(err)
105+
}
106+
}

0 commit comments

Comments
 (0)