nomad: FSM enqueues evaluations

This commit is contained in:
Armon Dadgar 2015-08-06 11:32:42 -07:00
parent 9398dc997b
commit b5100eeefb
2 changed files with 14 additions and 0 deletions

View File

@ -200,6 +200,13 @@ func (n *nomadFSM) applyUpdateEval(buf []byte, index uint64) interface{} {
n.logger.Printf("[ERR] nomad.fsm: UpsertEval failed: %v", err)
return err
}
if req.Eval.ShouldEnqueue() {
if err := n.evalBroker.Enqueue(req.Eval); err != nil {
n.logger.Printf("[ERR] nomad.fsm: failed to enqueue evaluation %s: %v", req.Eval.ID, err)
return err
}
}
return nil
}

View File

@ -229,6 +229,7 @@ func TestFSM_DeregisterJob(t *testing.T) {
func TestFSM_UpdateEval(t *testing.T) {
fsm := testFSM(t)
fsm.evalBroker.SetEnabled(true)
req := structs.EvalUpdateRequest{
Eval: mockEval(),
@ -254,6 +255,12 @@ func TestFSM_UpdateEval(t *testing.T) {
if eval.CreateIndex != 1 {
t.Fatalf("bad index: %d", eval.CreateIndex)
}
// Verify enqueued
stats := fsm.evalBroker.Stats()
if stats.TotalReady != 1 {
t.Fatalf("bad: %#v %#v", stats, eval)
}
}
func TestFSM_DeleteEval(t *testing.T) {