Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed May 25, 2016
1 parent bd079a2 commit 230b663
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 3 additions & 6 deletions nomad/blocked_evals.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ func (b *BlockedEvals) Block(eval *structs.Evaluation) {
}

// Check if the eval missed an unblock while it was in the scheduler at an
// older index.
// older index. The scheduler could have been invoked with a snapshot of
// state that was prior to additional capacity being added or allocations
// becoming terminal.
if b.missedUnblock(eval) {
// Just re-enqueue the eval immediately
b.evalBroker.Enqueue(eval)
Expand Down Expand Up @@ -258,11 +260,6 @@ func (b *BlockedEvals) unblock(computedClass string, index uint64) {
return
}

// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occured.
b.unblockIndexes[computedClass] = index

// Every eval that has escaped computed node class has to be unblocked
// because any node could potentially be feasible.
var unblocked []*structs.Evaluation
Expand Down
11 changes: 9 additions & 2 deletions nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/hashicorp/serf/serf"
)

const (
// failedEvalUnblockInterval is the interval at which failed evaluations are
// unblocked to re-enter the scheduler. A failed evaluation occurs under
// high contention when the schedulers plan does not make progress.
failedEvalUnblockInterval = 1 * time.Minute
)

// monitorLeadership is used to monitor if we acquire or lose our role
// as the leader in the Raft cluster. There is some work the leader is
// expected to do, so we must react to changes
Expand Down Expand Up @@ -346,11 +353,11 @@ func (s *Server) reapDupBlockedEvaluations(stopCh chan struct{}) {

// periodicUnblockFailedEvals periodically unblocks failed, blocked evaluations.
func (s *Server) periodicUnblockFailedEvals(stopCh chan struct{}) {
ticker := time.NewTimer(1 * time.Minute)
ticker := time.NewTimer(failedEvalUnblockInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
ticker.Stop()
return
case <-ticker.C:
// Unblock the failed allocations
Expand Down
2 changes: 1 addition & 1 deletion scheduler/generic_sched_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func TestServiceSched_EvaluateBlockedEval_Finished(t *testing.T) {
// Ensure the eval has no spawned blocked eval
if len(h.Evals) != 1 {
t.Fatalf("bad: %#v", h.Evals)
if h.Evals[0].SpawnedBlockedEval != "" {
if h.Evals[0].BlockedEval != "" {
t.Fatalf("bad: %#v", h.Evals[0])
}
}
Expand Down

0 comments on commit 230b663

Please sign in to comment.