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 // NewServiceScheduler is a factory function to instantiate a new service scheduler
func NewServiceScheduler(logger *log.Logger, state State, planner Planner) Scheduler { func NewServiceScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{ s := &GenericScheduler{
logger: logger, logger: logger,
state: state, state: state,
planner: planner, planner: planner,
batch: false, batch: false,
queuedAllocs: make(map[string]int),
} }
return s 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 // NewBatchScheduler is a factory function to instantiate a new batch scheduler
func NewBatchScheduler(logger *log.Logger, state State, planner Planner) Scheduler { func NewBatchScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{ s := &GenericScheduler{
logger: logger, logger: logger,
state: state, state: state,
planner: planner, planner: planner,
batch: true, batch: true,
queuedAllocs: make(map[string]int),
} }
return s 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 // 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. // further work or we've made the maximum number of attempts.
func (s *GenericScheduler) process() (bool, error) { func (s *GenericScheduler) process() (bool, error) {
s.queuedAllocs = make(map[string]int)
// Lookup the Job by ID // Lookup the Job by ID
var err error var err error
s.job, err = s.state.JobByID(s.eval.JobID) s.job, err = s.state.JobByID(s.eval.JobID)

View File

@ -45,10 +45,9 @@ type SystemScheduler struct {
// scheduler. // scheduler.
func NewSystemScheduler(logger *log.Logger, state State, planner Planner) Scheduler { func NewSystemScheduler(logger *log.Logger, state State, planner Planner) Scheduler {
return &SystemScheduler{ return &SystemScheduler{
logger: logger, logger: logger,
state: state, state: state,
planner: planner, planner: planner,
queuedAllocs: make(map[string]int),
} }
} }
@ -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 // 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. // further work or we've made the maximum number of attempts.
func (s *SystemScheduler) process() (bool, error) { func (s *SystemScheduler) process() (bool, error) {
s.queuedAllocs = make(map[string]int)
// Lookup the Job by ID // Lookup the Job by ID
var err error var err error
s.job, err = s.state.JobByID(s.eval.JobID) s.job, err = s.state.JobByID(s.eval.JobID)