mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Address more code review feedback
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user