@@ -61,27 +61,10 @@ func NewScheduler(
6161
6262// Run runs the Scheduler
6363func (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