Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#414 from k82cn/kb_412
Browse files Browse the repository at this point in the history
Added --schedule-period
  • Loading branch information
k8s-ci-robot authored Oct 11, 2018
2 parents a2030fd + 9635ac4 commit 504f054
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,27 @@ import (
)

type Scheduler struct {
cache schedcache.Cache
config *rest.Config
actions []framework.Action
pluginArgs []*framework.PluginArgs
schedulerConf string
cache schedcache.Cache
config *rest.Config
actions []framework.Action
pluginArgs []*framework.PluginArgs
schedulerConf string
schedulePeriod time.Duration
}

func NewScheduler(
config *rest.Config,
schedulerName string,
conf string,
period string,
nsAsQueue bool,
) (*Scheduler, error) {
sp, _ := time.ParseDuration(period)
scheduler := &Scheduler{
config: config,
schedulerConf: conf,
cache: schedcache.New(config, schedulerName, nsAsQueue),
config: config,
schedulerConf: conf,
cache: schedcache.New(config, schedulerName, nsAsQueue),
schedulePeriod: sp,
}

return scheduler, nil
Expand All @@ -69,7 +73,7 @@ func (pc *Scheduler) Run(stopCh <-chan struct{}) {

pc.actions, pc.pluginArgs = loadSchedulerConf(conf)

go wait.Until(pc.runOnce, 1*time.Second, stopCh)
go wait.Until(pc.runOnce, pc.schedulePeriod, stopCh)
}

func (pc *Scheduler) runOnce() {
Expand Down

0 comments on commit 504f054

Please sign in to comment.