nomad: FSM enqueues evaluations
This commit is contained in:
parent
9398dc997b
commit
b5100eeefb
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue