Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nomad: compare current eval when setting WaitIndex #5381

Merged
merged 4 commits into from
Mar 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nomad: simplify code and improve parameter name
  • Loading branch information
schmichael committed Mar 4, 2019
commit b47b1f1cda12892bcf655e61d6e96e9522bf0552
15 changes: 5 additions & 10 deletions nomad/eval_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (e *Eval) Dequeue(args *structs.EvalDequeueRequest,
// invoking the scheduler. The index should be the highest modify index of any
// evaluation for the job. This prevents scheduling races for the same job when
// there are blocked evaluations.
func (e *Eval) getWaitIndex(namespace, job string, curIndex uint64) (uint64, error) {
func (e *Eval) getWaitIndex(namespace, job string, evalModifyIndex uint64) (uint64, error) {
snap, err := e.srv.State().Snapshot()
if err != nil {
return 0, err
Expand All @@ -144,21 +144,16 @@ func (e *Eval) getWaitIndex(namespace, job string, curIndex uint64) (uint64, err
return 0, err
}

var max uint64
// Since dequeueing evals is concurrent with applying raft messages to
// the state store, initialize to the currently dequeued eval's index
// in case it isn't in the snapshot used by EvalsByJob yet.
max := evalModifyIndex
for _, eval := range evals {
if max < eval.ModifyIndex {
max = eval.ModifyIndex
}
}

// Since dequeueing evals is concurrent with applying raft messages to
// the state store, manually compare the currently dequeued eval's
// index against max in case it wasn't in the snapshot used by
// EvalsByJob yet.
if max < curIndex {
max = curIndex
}

return max, nil
}

Expand Down