Address more code review feedback

This commit is contained in:
Preetha Appan
2018-03-12 14:32:43 -05:00
parent 9bccc53857
commit 854ae91ae2
2 changed files with 7 additions and 5 deletions

View File

@@ -700,7 +700,9 @@ func (b *EvalBroker) flush() {
}
// Cancel the delayed evaluations goroutine
b.delayedEvalCancelFunc()
if b.delayedEvalCancelFunc != nil {
b.delayedEvalCancelFunc()
}
// Clear out the update channel for delayed evaluations
b.delayedEvalsUpdateCh = make(chan struct{}, 1)
@@ -742,16 +744,14 @@ func (d *evalWrapper) Namespace() string {
func (b *EvalBroker) runDelayedEvalsWatcher(ctx context.Context) {
var timerChannel <-chan time.Time
var delayTimer *time.Timer
init := false
for {
eval, waitUntil := b.nextDelayedEval()
if waitUntil.IsZero() {
timerChannel = nil
} else {
launchDur := waitUntil.Sub(time.Now().UTC())
if !init {
if delayTimer == nil {
delayTimer = time.NewTimer(launchDur)
init = true
} else {
delayTimer.Reset(launchDur)
}

View File

@@ -429,6 +429,9 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul
// Update the set of placement nodes
s.stack.SetNodes(nodes)
// Capture current time to use as the start time for any rescheduled allocations
now := time.Now()
// Have to handle destructive changes first as we need to discount their
// resources. To understand this imagine the resources were reduced and the
// count was scaled up.
@@ -491,7 +494,6 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul
// If the new allocation is replacing an older allocation then we
// set the record the older allocation id so that they are chained
if prevAllocation != nil {
now := time.Now()
alloc.PreviousAllocation = prevAllocation.ID
if missing.IsRescheduling() {
updateRescheduleTracker(alloc, prevAllocation, now)