Initializing the queued allocations late

This commit is contained in:
Diptanu Choudhury 2016-07-22 16:48:42 -07:00
parent 09aa867cc2
commit 51cb201a09
2 changed files with 13 additions and 14 deletions

View File

@ -78,11 +78,10 @@ type GenericScheduler struct {
// NewServiceScheduler is a factory function to instantiate a new service scheduler
func NewServiceScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger,
state: state,
planner: planner,
batch: false,
queuedAllocs: make(map[string]int),
logger: logger,
state: state,
planner: planner,
batch: false,
}
return s
}
@ -90,11 +89,10 @@ func NewServiceScheduler(logger *log.Logger, state State, planner Planner) Sched
// NewBatchScheduler is a factory function to instantiate a new batch scheduler
func NewBatchScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger,
state: state,
planner: planner,
batch: true,
queuedAllocs: make(map[string]int),
logger: logger,
state: state,
planner: planner,
batch: true,
}
return s
}
@ -181,6 +179,7 @@ func (s *GenericScheduler) createBlockedEval(planFailure bool) error {
// process is wrapped in retryMax to iteratively run the handler until we have no
// further work or we've made the maximum number of attempts.
func (s *GenericScheduler) process() (bool, error) {
s.queuedAllocs = make(map[string]int)
// Lookup the Job by ID
var err error
s.job, err = s.state.JobByID(s.eval.JobID)

View File

@ -45,10 +45,9 @@ type SystemScheduler struct {
// scheduler.
func NewSystemScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
return &SystemScheduler{
logger: logger,
state: state,
planner: planner,
queuedAllocs: make(map[string]int),
logger: logger,
state: state,
planner: planner,
}
}
@ -86,6 +85,7 @@ func (s *SystemScheduler) Process(eval *structs.Evaluation) error {
// process is wrapped in retryMax to iteratively run the handler until we have no
// further work or we've made the maximum number of attempts.
func (s *SystemScheduler) process() (bool, error) {
s.queuedAllocs = make(map[string]int)
// Lookup the Job by ID
var err error
s.job, err = s.state.JobByID(s.eval.JobID)