Skip to content

Commit

Permalink
Return an error if evaluation doesn't exist in state store at plan ap…
Browse files Browse the repository at this point in the history
…ply time.
  • Loading branch information
Preetha Appan committed Dec 18, 2017
1 parent f12255e commit aa35b5b
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 12 deletions.
4 changes: 2 additions & 2 deletions nomad/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ func (n *nomadFSM) Restore(old io.ReadCloser) error {
return nil
}

// reconcileSummaries re-calculates the queued allocations for every job that we
// reconcileQueuedAllocations re-calculates the queued allocations for every job that we
// created a Job Summary during the snap shot restore
func (n *nomadFSM) reconcileQueuedAllocations(index uint64) error {
// Get all the jobs
Expand Down Expand Up @@ -1142,7 +1142,7 @@ func (n *nomadFSM) reconcileQueuedAllocations(index uint64) error {
Status: structs.EvalStatusPending,
AnnotatePlan: true,
}

snap.UpsertEvals(100, []*structs.Evaluation{eval})
// Create the scheduler and run it
sched, err := scheduler.NewScheduler(eval.Type, n.logger, snap, planner)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,10 +1501,7 @@ func (s *StateStore) updateEvalModifyIndex(txn *memdb.Txn, index uint64, evalID
return fmt.Errorf("eval lookup failed: %v", err)
}
if existing == nil {
// return if there isn't an eval with this ID.
// In some cases (like snapshot restores), we process evals that are not already in the state store.
s.logger.Printf("[WARN] state_store: unable to find eval ID %v, cannot update modify index ", evalID)
return nil
return fmt.Errorf("[ERR] state_store: unable to find eval id %q", evalID)
}
eval := existing.(*structs.Evaluation).Copy()
// Update the indexes
Expand Down
Loading

0 comments on commit aa35b5b

Please sign in to comment.